// also consider System.nanoTime() and readline() with strtok()
import java.io.*;
import java.util.*;
public class FileScan
{
public static void main( String[] args ) throws IOException
{
long start = System.currentTimeMillis();
commandLineParameterCheck( args );
Scanner s = null;
try {
s = new Scanner( new BufferedReader( new FileReader( args[0] ) ));
while( s.hasNext() )
{
System.out.println( s.next() );
}
}finally {
if (s != null) { s.close(); }
}
long end = System.currentTimeMillis();
long duration = end - start;
System.out.println( duration + " ms" );
}
private static void commandLineParameterCheck( String[] args )
{
if( args.length != 1 || args[0].isEmpty() )
{
System.out.println( args.length + " does not equal the 1 required arguments.");
System.out.println( "version 0.1: java -jar filescan.jar filename" );
System.exit( 1 );
}
}
} //end class