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) { }