ReverseFile.java

import java.io.*;

class ReverseFile {
    static public void main(String[] arg) {
	String line;
	BufferedReader file=null;

	//Exit if the user forgot to specify a file
	if (arg.length < 1) {
	    System.out.println("Must give a file name.");
	    System.exit(0);
	}

	//Open the file
	try {
	    file = new BufferedReader(new FileReader(arg[0]));
	} catch (Exception e) { 
	    System.out.println(e); 
	    System.exit(0);
	}


	//Try to reverse it
	try {
	    Stack stack = new Stack();
	    while ((line=file.readLine()) != null) stack.push(line);
	    while ( stack.notEmpty() ) System.out.println(stack.pop());
	} catch (Exception e) { 
	    System.out.println(e); 
	    System.exit(0);
	}
    }
}

Generated by GNU enscript 1.6.3.