public static List < String > readFileToLinesList ( File file ) throws IOException { List < String > lines = new ArrayList <> ( ) ; try ( BufferedReader br = new BufferedReader ( new FileReader ( file ) ) ) { String line ; while ( ( line = br . readLine ( ) ) != null ) { lines . add ( line ) ; } return lines ; } }
Read text from a file to a list of lines .