import java.io.*; /** * This class takes a parameter on the command line, and prints the file * given to standard out. * * @author JJ Johns **/ public class cat { public static void main(String[] args) { FileReader reader = null; try { reader = new FileReader(args[0]); } catch(ArrayIndexOutOfBoundsException aeo) { System.out.println("Usage: java cat FILENAME"); System.exit(0); } catch(FileNotFoundException fnfe) { System.out.println("File named " + args[0] + " was not found."); System.exit(0); } try { int c; while( (c = reader.read()) != -1 ) { // cast the character and print it. System.out.print((char)c); } } catch (IOException eofe) { eofe.printStackTrace(); } } }