@ SuppressWarnings ( "DefaultCharset" ) public static String readFileOrThrow ( File file ) throws IOException { try ( Reader reader = new FileReader ( file ) ) { char [ ] buf = new char [ 8192 ] ; int len ; StringBuilder s = new StringBuilder ( ) ; while ( ( len = reader . read ( buf ) ) >= 0 ) { s . append ( buf , 0 , len ) ; } return s . toString ( ) ; } }
Reads the contents of a File .