// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class ReadLine {
    private static void test(String fnm, int expect) throws IOException {
        long t1 = System.currentTimeMillis();
        try(BufferedReader br = new BufferedReader(new FileReader(fnm))) {
            int n = 0;
            @SuppressWarnings("unused")
            String line;
            while((line = br.readLine()) != null) {
                n++;
            }
            if(n != expect) {
                System.out.printf("%d lines\n", n);
            }
        }
        long t2 = System.currentTimeMillis();
        System.out.printf("Java BufferedReader.readLine : %d ms\n", t2 - t1);
    }
    public static void main(String[] args) throws IOException {
        for(int i = 0; i < 10; i++) {
            test(args[0], Integer.parseInt(args[1]));
        }
    }
}
