日期:2014-05-20 浏览次数:20834 次
/**
* 获取文件行数
* @param fileName - 文件路径
* @return 文件行数
*/
public static Integer getRowCount(String fileName) {
Integer rowCount = 0;
File f = new File(fileName);
long length = f.length();
LineNumberReader lnr = null;
try {
lnr = new LineNumberReader(new FileReader(f));
if (lnr != null) {
lnr.skip(length);
rowCount = lnr.getLineNumber();
lnr.close();
}
} catch (IOException e) {
if (lnr != null) {
try {
lnr.close();
} catch (IOException ee) {
}
}
}
return rowCount;
}