Here you can find the source of readTextFile(String fileName)
public static ArrayList<String> readTextFile(String fileName)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.ArrayList; public class Main { public static ArrayList<String> readTextFile(String fileName) { ArrayList<String> strs = new ArrayList<String>(); try {// w ww . j a va 2 s .c o m BufferedReader bin = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileName)))); String line; while ((line = bin.readLine()) != null) { line = line.trim(); if (line.length() != 0) strs.add(line); } if (bin != null) { bin.close(); } } catch (IOException e) { System.err.println("Error when processing " + fileName); e.printStackTrace(System.err); } return strs; } }