Java Text File Read Line readLines(String filePath)

Here you can find the source of readLines(String filePath)

Description

read Lines

License

Open Source License

Declaration

public static List<String> readLines(String filePath) throws IOException 

Method Source Code

//package com.java2s;
/*//from w w  w  .  j  ava2s  .c  o  m
 * Copyright 2010
 * IBB-CEB - Institute for Biotechnology and Bioengineering - Centre of Biological Engineering
 * CCTC - Computer Science and Technology Center
 *
 * University of Minho 
 * 
 * This is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * This code 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 Public License for more details. 
 * 
 * You should have received a copy of the GNU Public License 
 * along with this code. If not, see http://www.gnu.org/licenses/ 
 * 
 * Created inside the SysBioPseg Research Group (http://sysbio.di.uminho.pt)
 */

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> readLines(String filePath) throws IOException {
        FileReader fr = new FileReader(filePath);
        BufferedReader br = new BufferedReader(fr);
        List<String> lines = new ArrayList<String>();
        String line;

        try {
            while ((line = br.readLine()) != null)
                lines.add(line);
        } finally {
            br.close();
            fr.close();
        }

        return lines;
    }
}

Related

  1. readLines(String fileName)
  2. readLines(String filename)
  3. readLines(String filename)
  4. readLines(String filename)
  5. readLines(String fileName)
  6. readLines(String filePath)
  7. readLines(String filePath)
  8. readLines(String fullFileName)
  9. readLines(String lines)