Here you can find the source of readFileAsListOfStrings(String filename)
public static List<String> readFileAsListOfStrings(String filename) throws Exception
//package com.java2s; import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; import java.util.List; public class Main { /**/*from ww w . j a v a2s .c om*/ * Open and read a file, and return the lines in the file as a list of * Strings. */ public static List<String> readFileAsListOfStrings(String filename) throws Exception { List<String> records = new ArrayList<String>(); try { BufferedReader reader = new BufferedReader(new FileReader(filename)); String line; while ((line = reader.readLine()) != null) { records.add(line); } reader.close(); return records; } catch (Exception e) { System.err.format("Exception occurred trying to read '%s'.", filename); e.printStackTrace(); throw e; } } }