Java BufferedReader Read readFile(String file)

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

Description

read File

License

Open Source License

Declaration

public static List<String> readFile(String file) 

Method Source Code


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

import java.io.BufferedReader;

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

import java.io.IOException;
import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> readFile(String file) {
        List<String> lines = new ArrayList<String>();
        File emailsFile = new File(file);
        try {/*  w ww  .j av  a  2 s  .c  om*/
            FileReader fread = new FileReader(emailsFile);
            BufferedReader buffReader = new BufferedReader(fread);
            String line = " ";
            while ((line = buffReader.readLine()) != null) {
                lines.add(line);
            }
            buffReader.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return lines;
    }
}

Related

  1. readFile(String directory)
  2. readFile(String directory, String fileName)
  3. readFile(String file)
  4. readFile(String file)
  5. readFile(String file)
  6. readFile(String file)
  7. readFile(String file)
  8. ReadFile(String file)
  9. readFile(String file)