private final File locate(String name){
  String prefix="";
  File sourceFile=null;
  int idx=0;
  while (true) {
    if ((idx == 0) && (ToolIO.getUserDir() != null)) {
      sourceFile=new File(ToolIO.getUserDir(),name);
    }
 else {
      if (isInJar(prefix)) {
        InputStream is=cl.getResourceAsStream(STANDARD_MODULES + name);
        if (is != null) {
          try {
            sourceFile=new File(TMPDIR + File.separator + name);
            sourceFile.deleteOnExit();
            FileOutputStream fos=new FileOutputStream(sourceFile);
            byte buf[]=new byte[1024];
            int len;
            while ((len=is.read(buf)) > 0) {
              fos.write(buf,0,len);
            }
            fos.close();
            is.close();
          }
 catch (          IOException e) {
            e.printStackTrace();
          }
        }
      }
 else {
        sourceFile=new File(prefix + name);
      }
    }
    if (sourceFile.exists())     break;
    if (idx >= libraryPaths.length)     break;
    prefix=libraryPaths[idx++];
  }
  return sourceFile;
}

private final File locate ( String name ) { String prefix = "" ; File sourceFile = null ; int idx = 0 ; while ( true ) { if ( ( idx == 0 ) && ( ToolIO . getUserDir ( ) != null ) ) { sourceFile = new File ( ToolIO . getUserDir ( ) , name ) ; } else { if ( isInJar ( prefix ) ) { InputStream is = cl . getResourceAsStream ( STANDARD_MODULES + name ) ; if ( is != null ) { try { sourceFile = new File ( TMPDIR + File . separator + name ) ; sourceFile . deleteOnExit ( ) ; FileOutputStream fos = new FileOutputStream ( sourceFile ) ; byte buf [ ] = new byte [ 1024 ] ; int len ; while ( ( len = is . read ( buf ) ) > 0 ) { fos . write ( buf , 0 , len ) ; } fos . close ( ) ; is . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } else { sourceFile = new File ( prefix + name ) ; } } if ( sourceFile . exists ( ) ) break ; if ( idx >= libraryPaths . length ) break ; prefix = libraryPaths [ idx ++ ] ; } return sourceFile ; }
from name , prepend path elements to try to find the actual file intended , and use the resulting fully - qualified name to initialize the file . the first fully - qualified name that refers to a file that actually exists is the file returned ; but if none exists , the last one tried is returned anyway . hence , the file object returned does not necessarily represent a file that actually exists in the file system .
