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 LinkedList<String> readLines(String filename) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.io.FileInputStream;

import java.io.InputStreamReader;

import java.io.FileInputStream;

import java.io.BufferedReader;

import java.util.LinkedList;

public class Main {
    public static String ENCODING = "UTF-8";

    public static LinkedList<String> readLines(String filename) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename), ENCODING));
        LinkedList<String> lines = new LinkedList<String>();
        while (true) {
            String line = reader.readLine();
            if (line == null)
                break;
            if (line.length() == 0)
                continue;
            lines.addLast(line);/* w ww  . j av  a 2s.  c  o  m*/
        }
        reader.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 filename)
  7. readLines(String fileName)
  8. readLines(String filePath)
  9. readLines(String filePath)