Java Text File Read Line readLines(String targetPath)

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

Description

read Lines

License

Open Source License

Declaration

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

Method Source Code


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

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 List<String> readLines(String targetPath) throws IOException {
        BufferedReader reader = null;
        try {//from w  ww .ja v a 2s . com
            reader = new BufferedReader(new FileReader(targetPath));
            List<String> rs = new ArrayList<String>();
            String line = reader.readLine();
            while (line != null) {
                rs.add(line);
                line = reader.readLine();
            }
            return rs;
        } finally {
            if (reader != null) {
                reader.close();
            }
        }
    }
}

Related

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