Here you can find the source of fileToLines(String filename)
public static List<String> fileToLines(String filename) throws IOException
//package com.java2s; /**************************************************************************** * Copyright (c) 2008-2014 Matthew Ballance and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from ww w.j a v a 2 s. c om*/ * Matthew Ballance - initial implementation ****************************************************************************/ import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.LinkedList; import java.util.List; public class Main { public static List<String> fileToLines(String filename) throws IOException { List<String> lines = new LinkedList<String>(); String line = ""; BufferedReader in = new BufferedReader(new FileReader(filename)); while ((line = in.readLine()) != null) { lines.add(line); } in.close(); return lines; } }