//按行读取本地文件
public static List<String> readFileByLines(String fileName) {
List<String> list = new ArrayList<>();
File file = new File(fileName);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
// 一次读一行,读入null时文件结束
while ((tempString = reader.readLine()) != null) {
list.add(tempString);
line++;
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
return list;
}