public String read ( ) { if ( mode . isReadable ( ) == false ) throw new IllegalStateException ( "IOError: not opened for reading" ) ; StringBuilder sb = new StringBuilder ( ) ; try { BufferedReader reader = new BufferedReader ( new FileReader ( file ) ) ; char [ ] buf = new char [ 1024 ] ; int numOfChars = 0 ; while ( ( numOfChars = reader . read ( buf ) ) != - 1 ) { sb . append ( String . valueOf ( buf , 0 , numOfChars ) ) ; } reader . close ( ) ; } catch ( IOException e ) { logger . log ( Level . SEVERE , null , e ) ; throw new RuntimeException ( e ) ; } return sb . toString ( ) ; }
Reads the content of a file .