Here you can find the source of readLines(String filename)
Parameter | Description |
---|---|
filename | a parameter |
public static List<String> readLines(String filename)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.List; import com.google.common.collect.Lists; public class Main { /**/* www . j a va 2 s . c om*/ * Read the lines of a file into a list of strings, with each line represented * as its own string. * * @param filename * @return */ public static List<String> readLines(String filename) { List<String> lines = Lists.newArrayList(); try { BufferedReader in = new BufferedReader(new FileReader(filename)); String line; while ((line = in.readLine()) != null) { // Ignore blank lines. if (line.trim().length() > 0) { lines.add(line); } } in.close(); } catch (IOException e) { throw new RuntimeException(e); } return lines; } }