@@ -0,0 +1,1035 @@
+/*  Copyright 2012 David Aparicio %0A * http://stackoverflow.com/questions/453018/number-of-lines-in-a-file-in-java%0A * This is the fastest version I have found so far,%0A * about 6 times faster than readLines. On a 150MB log file this takes 0.35 seconds,%0A * versus 2.40 seconds when using readLines(). Just for fun,%0A * linux' wc -l command takes 0.15 seconds.%0A * */%0Apackage inspiracio.io;%0A%0Aimport java.io.IOException;%0Aimport java.io.FileInputStream;%0Aimport java.io.BufferedInputStream;%0Aimport java.io.InputStream;%0A%0Apublic class Utils%7B%0A%09public static int count(String filename) throws IOException %7B%0A%09    InputStream is = new BufferedInputStream(new FileInputStream(filename));%0A%09    try %7B%0A%09        byte%5B%5D c = new byte%5B1024%5D;%0A%09        int count = 0;%0A%09        int readChars = 0;%0A%09        while ((readChars = is.read(c)) != -1) %7B%0A%09            for (int i = 0; i %3C readChars; ++i) %7B%0A%09                if (c%5Bi%5D == '%5Cn')%0A%09                    ++count;%0A%09            %7D%0A%09        %7D%0A%09        return count;%0A%09    %7D finally %7B%0A%09        is.close();%0A%09    %7D%0A%09%7D%0A%7D

Add the main function on the CSVReader, some JUnit tests, and Count() Signed-off-by: David Aparicio <david.aparicio@free.fr>