Text Streams

All of the text-oriented classes are derived from Reader and Writer. By understanding them, you'll have a handle on dealing with their descendents.

Writer

The Writer class writes character data to a stream. It has the following methods:

  • write(c)— writes a single character to the text stream

  • write(cbuf)— writes a sequence of characters to the text stream

  • write(cbuf, off, len)— writes a sequence of characters to the text stream starting at the offset into the stream and copying to len in the buffer

  • write(str)— writes out a string to the text stream

  • write(str, off, len)— writes out a string from the given offset to the given length

  • close()— closes the text stream

  • flush()— flushes the content of the text stream; used if the stream supports ...

Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.