Here you can find the source of readFile(File file)
public static List<String> readFile(File file)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> readFile(File file) { List<String> lines = new ArrayList<String>(); try {//w w w . j a v a2 s . c om FileInputStream fstream = new FileInputStream(file); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line; // Read File Line By Line while ((line = br.readLine()) != null) { lines.add(line); } br.close(); } catch (Exception e) { e.printStackTrace(); } return lines; } }