Java BufferedReader Read readFileAsLines(String aFile)

Here you can find the source of readFileAsLines(String aFile)

Description

read File As Lines

License

Apache License

Declaration

public static List<String> readFileAsLines(String aFile)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;

import java.io.FileReader;
import java.io.IOException;

import java.util.List;

import java.util.Vector;

public class Main {
    public static List<String> readFileAsLines(String aFile)
            throws IOException {
        BufferedReader input = new BufferedReader(new FileReader(aFile));
        List<String> lines = new Vector<String>();
        try {// w w w .  java  2  s . c  o  m
            String line = null; //not declared within while loop
            /*
             * readLine is a bit quirky :
             * it returns the content of a line MINUS the newline.
             * it returns null only for the END of the stream.
             * it returns an empty String if two newlines appear in a row.
             */
            while ((line = input.readLine()) != null) {
                lines.add(line);
            }
        } finally {
            input.close();
        }
        return lines;
    }
}

Related

  1. readFile(String sFileName_)
  2. readFile(String uri)
  3. readFile(String xmlFile)
  4. readFileAsHash(File file)
  5. readFileAsLines(File fileLocation)
  6. readFileAsList(final String filename)
  7. readFileAsList(String filename, String splitter)
  8. readFileAsListOfString(String fileName, String splitBy)
  9. readFileAsListOfStrings(String filename)