Here you can find the source of readFile(File file)
public static ArrayList<String> readFile(File file)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class Main { public static ArrayList<String> readFile(File file) { return readFile(file, "UTF8"); }//from w ww .ja v a2 s . co m public static ArrayList<String> readFile(File file, String encoding) { ArrayList<String> lines = new ArrayList<String>(50); if (!file.exists()) { throw new IllegalStateException("Unable to find File " + file + " bye"); } //if String line; boolean end = false; try { BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding)); while (!end) { line = br.readLine(); if (line == null) { end = true; } else { lines.add(line); } } //while br.close(); } //try catch (IOException ioe) { System.err.println("Unable to open file"); System.exit(-1); } return lines; } }