protected static String readFromFile(final File file) throws IOException {
  final LineNumberReader r=new LineNumberReader(new FileReader(file));
  try {
    final StringBuilder sb=new StringBuilder();
    String s;
    while ((s=r.readLine()) != null) {
      if (r.getLineNumber() > 1)       sb.append("\n");
      sb.append(s);
    }
    return sb.toString();
  }
  finally {
    r.close();
  }
}

protected static String readFromFile ( final File file ) throws IOException { final LineNumberReader r = new LineNumberReader ( new FileReader ( file ) ) ; try { final StringBuilder sb = new StringBuilder ( ) ; String s ; while ( ( s = r . readLine ( ) ) != null ) { if ( r . getLineNumber ( ) > 1 ) sb . append ( "\n" ) ; sb . append ( s ) ; } return sb . toString ( ) ; } finally { r . close ( ) ; } }
read the contents of a file .
