Monday, July 16, 2012

Java : Count lines in file


long lines = 1;
        try {
LineNumberReader  lnr = new LineNumberReader(new FileReader(new File("C:/testfile.txt")));
lnr.skip(Long.MAX_VALUE);
lines = lnr.getLineNumber();
} catch (FileNotFoundException e1) {
} catch (IOException e) {
}

The faster way to get total line in file...

No comments:

Post a Comment