public static File locateFile(String name,String basedir){
  File f=new File(name);
  if (f.exists()) {
    return f;
  }
  if (basedir != null) {
    f=new File(basedir,name);
    if (f.exists()) {
      return f;
    }
  }
{
    String name2=name.trim();
    if (!name.equals(name2)) {
      f=locateFile(name2,basedir);
      if (f != null) {
        return f;
      }
    }
  }
{
    String name2=name.replace('/',File.separatorChar);
    if (!name.equals(name2)) {
      f=locateFile(name2,basedir);
      if (f != null) {
        return f;
      }
    }
    name2=name.replace('\\',File.separatorChar);
    if (!name.equals(name2)) {
      f=locateFile(name2,basedir);
      if (f != null) {
        return f;
      }
    }
  }
  if (name.length() > 2 && name.charAt(0) == '"' && name.charAt(name.length() - 1) == '"') {
    f=locateFile(name.substring(1,name.length() - 1),basedir);
    if (f != null) {
      return f;
    }
  }
  return null;
}

public static File locateFile ( String name , String basedir ) { File f = new File ( name ) ; if ( f . exists ( ) ) { return f ; } if ( basedir != null ) { f = new File ( basedir , name ) ; if ( f . exists ( ) ) { return f ; } } { String name2 = name . trim ( ) ; if ( ! name . equals ( name2 ) ) { f = locateFile ( name2 , basedir ) ; if ( f != null ) { return f ; } } } { String name2 = name . replace ( '/' , File . separatorChar ) ; if ( ! name . equals ( name2 ) ) { f = locateFile ( name2 , basedir ) ; if ( f != null ) { return f ; } } name2 = name . replace ( '\\' , File . separatorChar ) ; if ( ! name . equals ( name2 ) ) { f = locateFile ( name2 , basedir ) ; if ( f != null ) { return f ; } } } if ( name . length ( ) > 2 && name . charAt ( 0 ) == '"' && name . charAt ( name . length ( ) - 1 ) == '"' ) { f = locateFile ( name . substring ( 1 , name . length ( ) - 1 ) , basedir ) ; if ( f != null ) { return f ; } } return null ; }
try to locate an file in the filesystem , given a partial name and a prefix .
