private StringBuffer loadFile(File file) throws IOException {
  String fileName=file.toString();
  StringBuffer sb=null;
synchronized (fileMap) {
    sb=(StringBuffer)fileMap.get(fileName);
  }
  if (sb != null) {
    return sb;
  }
  BufferedReader in=null;
  try {
    if (!file.canRead()) {
      throw new IOException("Can read file " + fileName);
    }
    in=new BufferedReader(new UnicodeInputStreamReader(new FileInputStream(file)));
    sb=new StringBuffer(2000);
    int ch;
    while ((ch=in.read()) != -1) {
      sb.append((char)ch);
    }
synchronized (fileMap) {
      fileMap.put(fileName,sb);
    }
    return sb;
  }
  finally {
    if (in != null) {
      in.close();
    }
  }
}

private StringBuffer loadFile ( File file ) throws IOException { String fileName = file . toString ( ) ; StringBuffer sb = null ; synchronized ( fileMap ) { sb = ( StringBuffer ) fileMap . get ( fileName ) ; } if ( sb != null ) { return sb ; } BufferedReader in = null ; try { if ( ! file . canRead ( ) ) { throw new IOException ( "Can read file " + fileName ) ; } in = new BufferedReader ( new UnicodeInputStreamReader ( new FileInputStream ( file ) ) ) ; sb = new StringBuffer ( 2000 ) ; int ch ; while ( ( ch = in . read ( ) ) != - 1 ) { sb . append ( ( char ) ch ) ; } synchronized ( fileMap ) { fileMap . put ( fileName , sb ) ; } return sb ; } finally { if ( in != null ) { in . close ( ) ; } } }
load file from file system
