O'Reilly logo

Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython by Richard Hightower

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Binary Streams: InputStream and OutputStream

InputStream is the analog of Reader; OutputStream is the analog of Writer. Their methods are listed here.

InputStream:

  • read(byte_sequence)— reads a sequence of bytes and returns the actual bytes read

  • read(byte_sequence, off, len)— same as above but allows you to set the slice for the sequence; returns the number of actual bytes read

  • read()— reads one byte of data from the input stream

  • skip(n)— skips to a given offset in the file

  • close()— closes the stream

  • reset()— moves the file pointer to the marked position

  • mark(iReadlimit)— marks the file pointer

  • available()— returns the number of bytes available that can be read without blocking (similar to the Reader class's ready() method)

OutputStream:

  • close()

  • flush() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required