统计文件行数
统计文件行数
public static int getTotalLines(String filePath) throws IOException {
LineNumberReader reader = new LineNumberReader(new FileReader(filePath));
reader.skip(Long.MAX_VALUE);
int lines = reader.getLineNumber();
reader.close();
return lines+1;
}