01: /*
02: * FlushCmd.java --
03: *
04: * Copyright (c) 1997 Sun Microsystems, Inc.
05: *
06: * See the file "license.terms" for information on usage and
07: * redistribution of this file, and for a DISCLAIMER OF ALL
08: * WARRANTIES.
09: *
10: * RCS: @(#) $Id: FlushCmd.java,v 1.2 2005/07/24 02:14:45 mdejong Exp $
11: *
12: */
13:
14: package tcl.lang;
15:
16: import java.util.*;
17: import java.io.*;
18:
19: /**
20: * This class implements the built-in "flush" command in Tcl.
21: */
22:
23: class FlushCmd implements Command {
24:
25: /**
26: * This procedure is invoked to process the "flush" Tcl command.
27: * See the user documentation for details on what it does.
28: *
29: * @param interp the current interpreter.
30: * @param argv command arguments.
31: */
32:
33: public void cmdProc(Interp interp, TclObject argv[])
34: throws TclException {
35:
36: Channel chan; /* The channel being operated on this method */
37:
38: if (argv.length != 2) {
39: throw new TclNumArgsException(interp, 1, argv, "channelId");
40: }
41:
42: chan = TclIO.getChannel(interp, argv[1].toString());
43: if (chan == null) {
44: throw new TclException(interp,
45: "can not find channel named \""
46: + argv[1].toString() + "\"");
47: }
48:
49: try {
50: chan.flush(interp);
51: } catch (IOException e) {
52: e.printStackTrace();
53: throw new TclRuntimeError(
54: "FlushCmd.cmdProc() Error: IOException when flushing "
55: + chan.getChanName());
56: }
57: }
58: }
|