Java BufferedReader Read loadLines(String fileName)

Here you can find the source of loadLines(String fileName)

Description

Load lines.

License

Open Source License

Parameter

Parameter Description
fileName the file name

Exception

Parameter Description
IOException Signals that an I/O exception has occurred.

Return

the list

Declaration

public static List<String> loadLines(String fileName) throws IOException 

Method Source Code

//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;
    }
}

Related

  1. loadLastExpInfo(String lastExpFileName)
  2. loadLine(InputStream load)
  3. loadLineByLineAndTrim(String file_path)
  4. loadLines(InputStream in, List lines)
  5. loadLines(String file)
  6. loadList(File f, String enc)
  7. loadList(final File file)
  8. loadList(String listName)
  9. loadListFromTextFile(String filename, String defaultitem, String linePrefix, String lineSuffix)