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.*; import java.util.*; public class Main { /**/*from www . j av a2 s .co m*/ * Just return each line of the file as String * * @param filename * @return */ public static List<String> readLines(String filename) { ArrayList<String> retval = new ArrayList<String>(); try { BufferedReader in = new BufferedReader(new FileReader(filename)); String curLine = in.readLine(); while (curLine != null) { retval.add(curLine.trim()); curLine = in.readLine(); } return retval; } catch (IOException ioe) { System.out.println(String.format("Bad file(name): %s\n", ioe.toString())); return null; } } }