Here you can find the source of readFile(File testPage)
Parameter | Description |
---|---|
testPage | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static List<String> readFile(File testPage) throws IOException
//package com.java2s; //License from project: Open Source License import static com.google.common.collect.Lists.newArrayList; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.List; public class Main { /**/* w w w . j a v a 2 s .c om*/ * Read a file into a List<String> * @param testPage * @return * @throws IOException */ public static List<String> readFile(File testPage) throws IOException { BufferedReader reader = null; try { List<String> lines = newArrayList(); FileReader fr = new FileReader(testPage); reader = new BufferedReader(fr); String line = reader.readLine(); while (line != null) { lines.add(line); line = reader.readLine(); } return lines; } finally { if (reader != null) { reader.close(); } } } }