private String readFileAsString ( File file ) throws java . io . IOException { StringBuilder fileData = new StringBuilder ( 1000 ) ; try ( BufferedReader reader = new BufferedReader ( ReaderFactory . newReader ( file , this . encoding ) ) ) { char [ ] buf = new char [ 1024 ] ; int numRead = 0 ; while ( ( numRead = reader . read ( buf ) ) != - 1 ) { String readData = String . valueOf ( buf , 0 , numRead ) ; fileData . append ( readData ) ; buf = new char [ 1024 ] ; } } return fileData . toString ( ) ; }
Read the given file and return the content as a string .