Interface Writer

All Known Implementing Classes:
StringW, WriterAdapter

public interface Writer
A character stream producer.

For compatibility with GWT, the native Java Writer implementation cannot be used.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the stream, flushing it first.
    void
    Flushes the stream.
    void
    write(char ch)
    Writes a single character.
    default void
    Writes a string.
    void
    write(String str, int start, int length)
    Writes a portion of a string.
  • Method Details

    • write

      void write(char ch) throws IOException
      Writes a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored.

      Subclasses that intend to support efficient single-character output should override this method.

      Parameters:
      ch - int specifying a character to be written
      Throws:
      IOException - If an I/O error occurs
    • write

      default void write(String str) throws IOException
      Writes a string.
      Parameters:
      str - String to be written
      Throws:
      IOException - If an I/O error occurs
    • write

      void write(String str, int start, int length) throws IOException
      Writes a portion of a string.
      Parameters:
      str - A String
      start - Offset from which to start writing characters
      length - Number of characters to write
      Throws:
      IndexOutOfBoundsException - If off is negative, or len is negative, or off+len is negative or greater than the length of the given string
      IOException - If an I/O error occurs
    • flush

      void flush() throws IOException
      Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
      Throws:
      IOException - If an I/O error occurs
    • close

      void close() throws IOException
      Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.
      Throws:
      IOException - If an I/O error occurs