Here you can find the source of readFileAsList(String path)
public static List<String> readFileAsList(String path) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> readFileAsList(String path) throws IOException { List<String> ls = new ArrayList<String>(); InputStream in = new FileInputStream(path); BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); String line = ""; while ((line = reader.readLine()) != null) { line = line.trim();// w w w. j a v a 2s. c o m if (line == null || "".equals(line)) { continue; } ls.add(line); } reader.close(); return ls; } public static List<String> readFileAsList(String path, String encode) throws IOException { List<String> ls = new ArrayList<String>(); InputStream in = new FileInputStream(path); BufferedReader reader = new BufferedReader(new InputStreamReader(in, encode)); String line = ""; while ((line = reader.readLine()) != null) { line = line.trim(); if (line == null || "".equals(line)) { continue; } ls.add(line); } reader.close(); return ls; } }