public static List<String> readToList(Reader r) throws IOException {
  try (BufferedReader in=new BufferedReader(r)){
    List<String> l=new ArrayList<>();
    String line=null;
    while ((line=in.readLine()) != null)     l.add(line);
    return Collections.unmodifiableList(l);
  }
 }

public static List < String > readToList ( Reader r ) throws IOException { try ( BufferedReader in = new BufferedReader ( r ) ) { List < String > l = new ArrayList < > ( ) ; String line = null ; while ( ( line = in . readLine ( ) ) != null ) l . add ( line ) ; return Collections . unmodifiableList ( l ) ; } }
read the reader line for line and return the result in a list
