public static int firstSymlinkIndex(String path)
  {
    int fromIndex = 0;
    int index;

    while ((index = path.indexOf('/', fromIndex)) >= 0)
    {
      fromIndex = index + 1;
      if (fromIndex < path.length() && path.charAt(fromIndex) == SYMLINK_PREFIX)
      {
        if (path.indexOf('/', fromIndex) != -1)
          return path.indexOf('/', fromIndex);
        else
          return path.length();
      }
    }
    return -1;
  }
@Test
  public void testFirstSymlinkIndex()
  {
    Assert.assertEquals(SymlinkUtil.firstSymlinkIndex(path1), path1.length());
    Assert.assertEquals(SymlinkUtil.firstSymlinkIndex(path2), path2.length());
    Assert.assertEquals(SymlinkUtil.firstSymlinkIndex(path3), path1.length());
    Assert.assertEquals(SymlinkUtil.firstSymlinkIndex(path4), -1);
    Assert.assertEquals(SymlinkUtil.firstSymlinkIndex(path5), -1);
  }