Java Text File Read Line readLines(File file)

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

Description

read Lines

License

Open Source License

Declaration

public static String[] readLines(File file) 

Method Source Code


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

import java.io.*;

import java.util.*;

public class Main {

    public static String[] readLines(File file) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)))) {
            ArrayList<String> res = new ArrayList<>();
            String line;//w w  w  .j a  v  a 2 s .com
            while ((line = in.readLine()) != null)
                res.add(line);
            return res.toArray(new String[0]);
        } catch (IOException e) {
            return null;
        }
    }

    public static String[] readLines(String file) {
        return readLines(new File(file));
    }
}

Related

  1. readLines(File file)
  2. readLines(File file)
  3. readLines(File file)
  4. readLines(File file)
  5. readLines(File file)
  6. readLines(File file)
  7. readLines(File file)
  8. readLines(File file)
  9. readLines(File file)