public static String pathMatch(String pathSpec, String path)
    {  
        char c = pathSpec.charAt(0);
        
        if (c=='/')
        {
            if (pathSpec.length()==1)
                return path;
        
            if (pathSpec.equals(path))
                return path;
            
            if (pathSpec.endsWith("/*") &&
                pathSpec.regionMatches(0,path,0,pathSpec.length()-2))
                return path.substring(0,pathSpec.length()-2);
            
            if (path.startsWith(pathSpec) && path.charAt(pathSpec.length())==';')
                return path;
        }
        else if (c=='*')
        {
            if (path.regionMatches(path.length()-(pathSpec.length()-1),
                                   pathSpec,1,pathSpec.length()-1))
                return path;
        }
        return null;
    }
public static String pathMatch ( String pathSpec , String path ) { char c = pathSpec . charAt ( 0 ) ; if ( c == '/' ) { if ( pathSpec . length ( ) == 1 ) return path ; if ( pathSpec . equals ( path ) ) return path ; if ( pathSpec . endsWith ( "/*" ) && pathSpec . regionMatches ( 0 , path , 0 , pathSpec . length ( ) - 2 ) ) return path . substring ( 0 , pathSpec . length ( ) - 2 ) ; if ( path . startsWith ( pathSpec ) && path . charAt ( pathSpec . length ( ) ) == ';' ) return path ; } else if ( c == '*' ) { if ( path . regionMatches ( path . length ( ) - ( pathSpec . length ( ) - 1 ) , pathSpec , 1 , pathSpec . length ( ) - 1 ) ) return path ; } return null ; }
Return the portion of a path that matches a path spec.
@return null if no match at all.