Java Text File Read Line readLines(String filename)

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

Description

read Lines

License

Open Source License

Declaration

public static String[] readLines(String filename) throws IOException 

Method Source Code

//package com.java2s;
/*// w w w.  ja va2  s . c om
 * Sonar MSBuild Plugin, open source software quality management tool.
 * Author(s) : Jorge Costa @ jmecsoftware.com
 * 
 * Sonar MSBuild Plugin 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.
 *
 * Sonar MSBuild Plugin 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.
 */

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 String[] readLines(String filename) throws IOException {
        FileReader fileReader = new FileReader(filename);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        List<String> lines = new ArrayList<String>();
        String line = null;
        while ((line = bufferedReader.readLine()) != null) {
            lines.add(line);
        }
        bufferedReader.close();
        return lines.toArray(new String[lines.size()]);
    }
}

Related

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