1.1 --- a/java/io.py Mon Jan 10 23:43:44 2005 +0100
1.2 +++ b/java/io.py Mon Jan 10 23:52:19 2005 +0100
1.3 @@ -1,6 +1,8 @@
1.4 #!/usr/bin/env python
1.5
1.6 -class InputStream(object):
1.7 +from java.lang._object import Object, NullPointerException, IndexOutOfBoundsException, Exception as _Exception
1.8 +
1.9 +class InputStream(Object):
1.10 def __init__(self, stream):
1.11 # NOTE: Python-only method.
1.12 self.stream = stream
1.13 @@ -12,15 +14,13 @@
1.14 return ord(s)
1.15 def read____B__array_(self, b, off=0, length=None):
1.16 if b is None:
1.17 - import java.lang
1.18 - raise java.lang.NullPointerException
1.19 + raise Exception, NullPointerException()
1.20 if len(b) == 0:
1.21 return 0
1.22 if length is None:
1.23 length = len(b)
1.24 elif length + off > len(b):
1.25 - import java.lang
1.26 - raise java.lang.IndexOutOfBoundsException
1.27 + raise Exception, IndexOutOfBoundsException()
1.28 s = self.stream.read(length)
1.29 if s == "":
1.30 return -1
1.31 @@ -53,14 +53,14 @@
1.32 raise NotImplementedError, "markSupported"
1.33 markSupported___ = markSupported
1.34
1.35 -class IOException(Exception):
1.36 +class IOException(_Exception):
1.37 def __init__(self, *args):
1.38 self.args = args
1.39
1.40 setattr(IOException, "__init_____", IOException.__init__)
1.41 setattr(IOException, "__init_____java__lang__String", IOException.__init__)
1.42
1.43 -class OutputStream(object):
1.44 +class OutputStream(Object):
1.45 def write(self, b, *args):
1.46 raise NotImplementedError, "write"
1.47 write___java__lang__String = write
1.48 @@ -108,14 +108,14 @@
1.49 def flush(self):
1.50 FilterOutputStream.flush(self)
1.51 flush___ = flush
1.52 - def print_(self, obj):
1.53 + def print_(self, obj, ending=""):
1.54 # NOTE: Check for arrays.
1.55 if isinstance(obj, list):
1.56 for i in obj:
1.57 - self.print_(i)
1.58 + self.print_(i, ending)
1.59 else:
1.60 # NOTE: Using Python string conversion.
1.61 - FilterOutputStream.write(self, unicode(obj))
1.62 + FilterOutputStream.write(self, unicode(obj) + ending)
1.63 print____Z_ = print_
1.64 print____C_ = print_
1.65 print____C__array_ = print_
1.66 @@ -126,6 +126,18 @@
1.67 print___java__lang__Object = print_
1.68 print___java__lang__String = print_
1.69
1.70 + def println(self, obj):
1.71 + self.print_(obj, "\n")
1.72 + println____Z_ = println
1.73 + println____C_ = println
1.74 + println____C__array_ = println
1.75 + println____D_ = println
1.76 + println____F_ = println
1.77 + println____I_ = println
1.78 + println____L_ = println
1.79 + println___java__lang__Object = println
1.80 + println___java__lang__String = println
1.81 +
1.82 # NOTE: To be completed.
1.83
1.84 setattr(PrintStream, "__init_____java__io__OutputStream", PrintStream.init__out)