1   // joi/6/juno/NewfileCommand.java                         
2   //                                                            
3   //                                                            
4   // Copyright 2003, Ethan Bolker and Bill Campbell                         
5                                                               
6   import java.util.*;
7   
8   /**
9    * The Juno shell command to create a text file.
10   * Usage:
11   * <pre>
12   *     newfile filename contents
13   * </pre>
14   *
15   * @version 6
16   */
17  
18  public class NewfileCommand extends ShellCommand 
19  {
20      /**
21       * Construct a NewfileCommand object.
22       */
23  
24      public NewfileCommand() 
25      {
26          super( "create a new TextFile", "filename contents" );
27      }
28  
29      /**
30       * Create a new TextFile in the current Directory.
31       *
32       * @param args the remainder of the command line.
33       * @param sh the current shell
34       */
35  
36      public void doIt( StringTokenizer args, Shell sh )
37      {
38          String filename = args.nextToken();
39          String contents = args.nextToken("").trim(); // rest of line
40          new TextFile( filename, sh.getUser(), sh.getDot(), contents );
41      }
42  }
43