Hi : Given an arbitrary file (java), I want to count the lines.
This is easy enough, for example, using Apache\'s FileUtils.readLines(...) method...
Howeve
With Guava:
int nLines = Files.readLines(file, charset, new LineProcessor() { int count = 0; Integer getResult() { return count; } boolean processLine(String line) { count++; return true; } });
which won't hold the whole file in memory or anything.