public static final String readFile(File file) throws IOException {
  BufferedInputStream in=null;
  try {
    in=new BufferedInputStream(new FileInputStream(file));
    SimpleByteBuffer buffer=new SimpleByteBuffer();
    byte[] buf=new byte[1024];
    int len;
    while ((len=in.read(buf)) != -1) {
      buffer.put(buf,len);
    }
    return new String(buffer.buffer,0,buffer.write);
  }
  finally {
    if (null != in) {
      in.close();
    }
  }
}

public static final String readFile ( File file ) throws IOException { BufferedInputStream in = null ; try { in = new BufferedInputStream ( new FileInputStream ( file ) ) ; SimpleByteBuffer buffer = new SimpleByteBuffer ( ) ; byte [ ] buf = new byte [ 1024 ] ; int len ; while ( ( len = in . read ( buf ) ) != - 1 ) { buffer . put ( buf , len ) ; } return new String ( buffer . buffer , 0 , buffer . write ) ; } finally { if ( null != in ) { in . close ( ) ; } } }
read small < 5mb text files to string .
