Here you can find the source of readFileOfList(String path)
public static List<String> readFileOfList(String path)
//package com.java2s; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> readFileOfList(String path) { List<String> list = new ArrayList<String>(); InputStreamReader ir = null; BufferedReader br = null; try {// w w w .j ava 2 s . c o m ir = new InputStreamReader(new FileInputStream(path), "UTF8"); br = new BufferedReader(ir); String data = br.readLine(); while (data != null) { if (!"".equals(data)) { list.add(data); } data = br.readLine(); } } catch (Exception e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } if (ir != null) { try { ir.close(); } catch (IOException e) { e.printStackTrace(); } } } return list; } }