// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package mapfile;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class Read2 {
	private static void test(String fnm) throws IOException {
		System.out.printf("%s %s / %s %s\n", System.getProperty("java.vendor"), System.getProperty("java.version"), System.getProperty("os.name"), System.getProperty("os.version"));
		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++;
			}
			System.out.printf("%d lines\n", n);
		}
		long t2 = System.currentTimeMillis();
		System.out.printf("Read one line at a time : %d ms\n", t2 - t1);
	}
	public static void main(String[] args) throws IOException {
		for(int i = 0; i < 3; i++) {
			test(args[0]);
		}
	}
}
