Java BufferedReader Read All readAll(File file)

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

Description

read All

License

Open Source License

Declaration

public static List<String> readAll(File file) 

Method Source Code


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

import java.io.BufferedReader;

import java.io.File;
import java.io.FileReader;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> readAll(File file) {
        List<String> data = new ArrayList<>();
        if (file.isDirectory() || !file.canRead() || !file.exists() || file.isHidden())
            return data;
        try (BufferedReader br = new BufferedReader(new FileReader(file))) {
            String read = null;//  w w w .  j a v a  2s.c o  m
            while ((read = br.readLine()) != null)
                data.add(read);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return data;
    }
}

Related

  1. readAll(File f)
  2. readAll(File file)
  3. readAll(File file)
  4. readAll(File input)
  5. readAll(final Reader reader)
  6. readAll(InputStream in)