class PathUtils {

    public static boolean pathEquals(String path1, String path2, String separator) {
        if(path1==null)
            return path2==null;

        if(path2==null)
            return path1==null;
        
        if(path1.equals(path2))
            return true;

        int len1 = path1.length();
        int len2 = path2.length();
        int separatorLen = separator.length();

        // If the difference between the 2 strings is just a trailing path separator, we consider the paths as equal
        if(Math.abs(len1-len2)==separatorLen && (len1>len2 ? path1.startsWith(path2) : path2.startsWith(path1))) {
            String diff = len1>len2 ? path1.substring(len1-separatorLen) : path2.substring(len2-separatorLen);
            return separator.equals(diff);
        }

        return false;
    }

}