public static String fromFile ( File file ) throws IOException { BufferedReader br = new BufferedReader ( new FileReader ( file ) ) ; StringBuilder sb = new StringBuilder ( ) ; String line = br . readLine ( ) ; while ( line != null ) { sb . append ( line ) ; line = br . readLine ( ) ; if ( line != null ) sb . append ( System . lineSeparator ( ) ) ; } br . close ( ) ; return sb . toString ( ) ; }
Reads the text from a text file