dcsimg

Is there an easy way of counting line numbers? Or do you have to go through the entire file?

Shahram Khorsand

You have to go through the entire file.

try {
  LineNumberReader lnr = new LineNumberReader(new FileReader(filename));
  String s;
  while ((s = lnr.readLine()) != null);
  System.out.println("Lines: " + lnr.getLineNumber());