01: /*
02: * @(#)readUTF.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: public class readUTF extends PnutsFunction {
15:
16: public readUTF() {
17: super ("readUTF");
18: }
19:
20: public boolean defined(int narg) {
21: return (narg == 1);
22: }
23:
24: protected Object exec(Object[] args, Context context) {
25: try {
26: if (args.length == 1) {
27: return ((DataInput) args[0]).readUTF();
28: } else {
29: undefined(args, context);
30: return null;
31: }
32: } catch (IOException e) {
33: throw new PnutsException(e, context);
34: }
35: }
36:
37: public String toString() {
38: return "function readUTF(DataInput)";
39: }
40: }
|