static public String
    locateRelative(String relpath, String abspath, boolean wantdir)
    {
        // clean up the path and filename
        relpath = relpath.trim().replace('\\', '/');
        if(relpath.charAt(0) == '/') relpath = relpath.substring(1);
        if(relpath.endsWith("/")) relpath = relpath.substring(0, relpath.length() - 1);
        String[] pieces = relpath.split("[/]");
        String partial = abspath;
        for(int i = 0; i < pieces.length - 1; i++) {
            String nextdir = locateFile(pieces[i], abspath, true);
            if(nextdir == null) return null;
            partial = nextdir;
        }
        // See if the final file|dir exists in this dir
        String finalpath = locateFile(pieces[pieces.length - 1], partial, wantdir);
        return finalpath;
    }
static public String
    locateRelative(String relpath, String abspath, boolean wantdir)
    {
        
        relpath = relpath.trim().replace('\\', '/');
        if(relpath.charAt(0) == '/') relpath = relpath.substring(1);
        if(relpath.endsWith("/")) relpath = relpath.substring(0, relpath.length() - 1);
        String[] pieces = relpath.split("[/]");
        String partial = abspath;
        for(int i = 0; i < pieces.length - 1; i++) {
            String nextdir = locateFile(pieces[i], abspath, true);
            if(nextdir == null) return null;
            partial = nextdir;
        }
        
        String finalpath = locateFile(pieces[pieces.length - 1], partial, wantdir);
        return finalpath;
    }
static public String locateRelative ( String relpath , String abspath , boolean wantdir ) { // clean up the path and filename relpath = relpath . trim ( ) . replace ( ' ' , ' ' ) ; if ( relpath . charAt ( 0 ) == ' ' ) relpath = relpath . substring ( 1 ) ; if ( relpath . endsWith ( "/" ) ) relpath = relpath . substring ( 0 , relpath . length ( ) - 1 ) ; String [ ] pieces = relpath . split ( "[/]" ) ; String partial = abspath ; for ( int i = 0 ; i < pieces . length - 1 ; i ++ ) { String nextdir = locateFile ( pieces [ i ] , abspath , true ) ; if ( nextdir == null ) return null ; partial = nextdir ; } // See if the final file|dir exists in this dir String finalpath = locateFile ( pieces [ pieces . length - 1 ] , partial , wantdir ) ; return finalpath ; }
Walk the specified dir tree to locate file specified by relative path.
Use breadth first search.

@param relpath Name of the file|dir to locate
@param abspath Absolute path from which to start search
@param wantdir True if we are looking for a directory,
false if we are looking for a file
@return absolute path of the file|dir wrt to abspath
Walk the specified dir tree to locate file specified by relative path . Use breadth first search .