public String readFileAsString ( String filePath ) throws IOException { String result = null ; Reader reader = new BufferedReader ( new FileReader ( filePath ) ) ; StringBuilder stringBuffer = new StringBuilder ( 4096 ) ; int charRead = - 1 ; while ( ( charRead = reader . read ( ) ) >= 0 ) { stringBuffer . append ( ( char ) charRead ) ; } reader . close ( ) ; result = stringBuffer . toString ( ) ; return result ; }
Read the contents of the given file and return the value as a string .