@Test public void testRemoveLeadingFragments() { assert "home/maxence/".equals(PathUtils.removeLeadingFragments("/home/maxence/", "/", 0)); assert "maxence/".equals(PathUtils.removeLeadingFragments("/home/maxence/", "/", 1)); assert "".equals(PathUtils.removeLeadingFragments("/home/maxence/", "/", 2)); assert "".equals(PathUtils.removeLeadingFragments("/home/maxence/", "/", 3)); assert "".equals(PathUtils.removeLeadingFragments("/home/maxence/", "\\", 1)); }
public static String removeLeadingFragments(String path, String separator, int nbFragments) { path = removeLeadingSeparator(path, separator); if(nbFragments==0) return path; int pos=-1; for(int i=0; i<nbFragments && (pos=path.indexOf(separator, pos+1))!=-1; i++); if(pos==-1 || pos==path.length()-1) return ""; return path.substring(pos+1); }
PathUtils { public static String removeLeadingFragments(String path, String separator, int nbFragments) { path = removeLeadingSeparator(path, separator); if(nbFragments==0) return path; int pos=-1; for(int i=0; i<nbFragments && (pos=path.indexOf(separator, pos+1))!=-1; i++); if(pos==-1 || pos==path.length()-1) return ""; return path.substring(pos+1); } }
PathUtils { public static String removeLeadingFragments(String path, String separator, int nbFragments) { path = removeLeadingSeparator(path, separator); if(nbFragments==0) return path; int pos=-1; for(int i=0; i<nbFragments && (pos=path.indexOf(separator, pos+1))!=-1; i++); if(pos==-1 || pos==path.length()-1) return ""; return path.substring(pos+1); }  }
PathUtils { public static String removeLeadingFragments(String path, String separator, int nbFragments) { path = removeLeadingSeparator(path, separator); if(nbFragments==0) return path; int pos=-1; for(int i=0; i<nbFragments && (pos=path.indexOf(separator, pos+1))!=-1; i++); if(pos==-1 || pos==path.length()-1) return ""; return path.substring(pos+1); }  static ResolvedDestination resolveDestination(String destPath, AbstractFile baseFolder); static String removeLeadingSeparator(String path); static String removeLeadingSeparator(String path, String separator); static String removeTrailingSeparator(String path); static String removeTrailingSeparator(String path, String separator); static boolean pathEquals(String path1, String path2, String separator); static int getPathHashCode(String path, String separator); static String removeLeadingFragments(String path, String separator, int nbFragments); static int getDepth(String path, String separator); }
PathUtils { public static String removeLeadingFragments(String path, String separator, int nbFragments) { path = removeLeadingSeparator(path, separator); if(nbFragments==0) return path; int pos=-1; for(int i=0; i<nbFragments && (pos=path.indexOf(separator, pos+1))!=-1; i++); if(pos==-1 || pos==path.length()-1) return ""; return path.substring(pos+1); }  static ResolvedDestination resolveDestination(String destPath, AbstractFile baseFolder); static String removeLeadingSeparator(String path); static String removeLeadingSeparator(String path, String separator); static String removeTrailingSeparator(String path); static String removeTrailingSeparator(String path, String separator); static boolean pathEquals(String path1, String path2, String separator); static int getPathHashCode(String path, String separator); static String removeLeadingFragments(String path, String separator, int nbFragments); static int getDepth(String path, String separator);  }