01: /*
02: * @(#)writeUTF.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.io;
10:
11: import pnuts.lang.*;
12: import java.io.*;
13:
14: /*
15: * writeUTF(DataOutput dout, String str)
16: */
17: public class writeUTF extends PnutsFunction {
18:
19: public writeUTF() {
20: super ("writeUTF");
21: }
22:
23: public boolean defined(int narg) {
24: return (narg == 2);
25: }
26:
27: public Object exec(Object[] args, Context context) {
28: int nargs = args.length;
29: try {
30: if (nargs == 2) {
31: DataOutput dout = (DataOutput) args[0];
32: String str = (String) args[1];
33: dout.writeUTF(str);
34: } else {
35: undefined(args, context);
36: }
37: return null;
38: } catch (IOException e) {
39: throw new PnutsException(e, context);
40: }
41: }
42:
43: public String toString() {
44: return "function writeUTF(DataOutput dout, String str)";
45: }
46: }
|