Here you can find the source of loadLines(String fileName)
Parameter | Description |
---|---|
fileName | the file name |
Parameter | Description |
---|---|
IOException | Signals that an I/O exception has occurred. |
public static List<String> loadLines(String fileName) throws IOException
//package com.java2s; /******************************************************************************* * =========================================================== * Ankush : Big Data Cluster Management Solution * =========================================================== * /* w w w. j a v a 2 s. co m*/ * (C) Copyright 2014, by Impetus Technologies * * This is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License (LGPL v3) as * published by the Free Software Foundation; * * This software 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 this software; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ******************************************************************************/ import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class Main { /** * Load lines. * * @param fileName the file name * @return the list * @throws IOException Signals that an I/O exception has occurred. */ public static List<String> loadLines(String fileName) throws IOException { List<String> lineList = new ArrayList<String>(); FileReader fr = new FileReader(fileName); BufferedReader br = new BufferedReader(fr); String line = null; do { line = br.readLine(); if (line != null) { lineList.add(line); } } while (line != null); br.close(); fr.close(); return lineList; } }