Java Text File Read Line readLines(String file)

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

Description

read Lines

License

Open Source License

Declaration

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

Method Source Code

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

import java.io.BufferedReader;

import java.io.FileInputStream;

import java.io.IOException;
import java.io.InputStreamReader;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> readLines(String file) throws IOException {

        BufferedReader reader = null;
        List<String> lines;
        String line;/*from  w w  w. j  a  v  a  2 s.c om*/

        lines = new ArrayList<String>();

        try {

            reader = new BufferedReader(new InputStreamReader(
                    new FileInputStream(file)));

            while ((line = reader.readLine()) != null)
                lines.add(line);

        } finally {

            if (reader != null)
                reader.close();
        }

        return lines;
    }
}

Related

  1. readLines(final File file)
  2. readlines(final File file)
  3. readLines(int problemNumber)
  4. readLines(String body)
  5. readLines(String file)
  6. readLines(String file, ArrayList lines)
  7. readLines(String filename)
  8. readLines(String fileName)
  9. readlines(String filename)