Here you can find the source of readLines(File f)
Parameter | Description |
---|---|
f | file object. |
Parameter | Description |
---|---|
IOException | if there were problems on reading the file. |
public static List<String> readLines(File f) throws IOException
//package com.java2s; /*//from www. j a va 2 s . c om * This file is part of Bukkit Plugin Utilities. * * Bukkit Plugin Utilities is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * Bukkit Plugin Utilities is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Bukkit Plugin Utilities. * If not, see <http://www.gnu.org/licenses/>. */ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class Main { /** * Reads all lines of a file into a string list. * * @param f * file object. * @return all lines of the file. * @throws IOException * if there were problems on reading the file. */ public static List<String> readLines(File f) throws IOException { List<String> lines = new ArrayList<String>(); FileReader fileReader = new FileReader(f); try { BufferedReader bufferedReader = new BufferedReader(fileReader); String line = null; while ((line = bufferedReader.readLine()) != null) { lines.add(line); } } finally { fileReader.close(); } return lines; } }