// joi/7/juno/TypeCommand.java // // // Copyright 2003, Bill Campbell and Ethan Bolker import java.util.*; /** * The Juno shell command to display the contents of a * text file. * Usage: *
* type textfile ** * @version 7 */ public class TypeCommand extends ShellCommand { TypeCommand() { super( "display contents of a TextFile", "textfile" ); } /** * Display the contents of a TextFile. * * @param args the remainder of the command line. * @param sh the current Shell * * @exception JunoException for reporting errors */ public void doIt( StringTokenizer args, Shell sh ) throws JunoException // EEE { String filename; try { // EEE filename = args.nextToken(); } // EEE catch (NoSuchElementException e) { throw new BadShellCommandException( this ); // EEE } // EEE try { // EEE sh.getConsole().println( ( (TextFile) sh.getDot(). retrieveJFile( filename ) ).getContents() ); } // EEE catch (NullPointerException e) { // EEE throw new JunoException( "JFile does not exist: " // EEE + filename); // EEE } // EEE catch (ClassCastException e) { // EEE throw new JunoException( "JFile not a text file: " // EEE + filename); // EEE } // EEE } }