Java按行读取文件工具类
import java.io.*;
import java.util.*;
public class FileReadUtil {
public static List<String> ReadFile(String file) {
List<String> list = new ArrayList<>();
String str;
try {
LineNumberReader reader = new LineNumberReader(new FileReader(file));
while ((str = reader.readLine()) != null) {
if (!str.isEmpty()) {
list.add(str);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return list;
}
}