public static String readFromFileIntoString ( File file ) throws IOException { FileInputStream inputStream = new FileInputStream ( file ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( inputStream , "UTF-8" ) ) ; StringBuilder text = new StringBuilder ( ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { text . append ( line ) . append ( "\n" ) ; } inputStream . close ( ) ; return text . toString ( ) ; }
This method reads all data from a file into a String object