String[] p = new String[paths.length]; for(int i = 0; i < p.length; i++) { p[i] = paths[i].replace(File.separatorChar, '/');
String root = paths[0].replace(File.separatorChar, '/'); for (int i = 1; i < paths.length; i++) { root = getCommonAncestor(root, paths[i].replace(File.separatorChar, '/')); } root = PathUtil.removeLeadingSlash(root); root = PathUtil.removeTrailingSlash(root); for(int i = 0; i < paths.length; i++) { if (paths[i].replace(File.separatorChar, '/').equals(root)) { root = PathUtil.removeTail(root); break; }
    public static String getCommonRoot(String[] paths) {        if (paths.length == 1) {            return PathUtil.removeLeadingSlash(PathUtil.removeTail(paths[0]));        }         String[] p = new String[paths.length];        for(int i = 0; i < p.length; i++) {            p[i] = paths[i].replace(File.separatorChar, '/');        }        String root = paths[0];        for (int i = 1; i < paths.length; i++) {			root = getCommonAncestor(root, paths[i]);		}        return PathUtil.removeLeadingSlash(PathUtil.removeTail(root));    }