Java Text File Read Line readLines(String string)

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

Description

read Lines

License

Apache License

Declaration

public static List<String> readLines(String string) 

Method Source Code

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

import java.io.BufferedReader;

import java.io.File;

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 string) {
        File file = new File(string);
        return readLines(file);
    }// w  ww  .j a  v a  2 s  .  c o  m

    public static List<String> readLines(File file) {
        List<String> lines = new ArrayList<String>();

        try {
            BufferedReader reader = new BufferedReader(new FileReader(file));
            String line = null;
            while ((line = reader.readLine()) != null) {
                lines.add(line);
            }
        } catch (IOException e) {
            throw new RuntimeException(String.format("Failed to read lines from file '%s'", file.getAbsolutePath()),
                    e);
        }

        return lines;

    }
}

Related

  1. readLines(String filePath)
  2. readLines(String filePath)
  3. readLines(String filePath)
  4. readLines(String fullFileName)
  5. readLines(String lines)
  6. readLines(String targetPath)
  7. readLines(String text)
  8. readLines(String text)
  9. readLines2Lowcase(String inputFile, ArrayList lines)