public String read ( ) throws IOException { StringWriter out = new StringWriter ( ) ; PrintWriter w = new PrintWriter ( out ) ; try ( BufferedReader in = Files . newBufferedReader ( Util . fileToPath ( file ) , StandardCharsets . UTF_8 ) ) { String line ; while ( ( line = in . readLine ( ) ) != null ) w . println ( line ) ; } catch ( Exception e ) { throw new IOException ( "Failed to fully read " + file , e ) ; } return out . toString ( ) ; }
Reads the entire contents and returns it .