Skip navigation links

Overview | Package | Class | Tree | Index | Help
| Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.io
Class Utf8Writer

`java.lang.Object
java.io.Writer
com.tangosol.io.Utf8Writer`

All Implemented Interfaces:
  Closeable, Flushable, Appendable

      public class Utf8Writer

extends Writer

A Utf8Writer is used to write character data onto an underlying stream.

Author:
  cp 2002.01.04

Field Summary

Fields inherited from class java.io.Writer
`lock`

Constructor Summary
`Utf8Writer()` Construct a Utf8Writer that buffers the output.
`Utf8Writer(OutputStream stream)` Construct a Utf8Writer that puts the output into an OutputStream.

Method Summary
`void` | `close()` Close the stream, flushing it first.
`void` | `flush()` Flush the stream.
`byte[]` | `toByteArray()` If the underlying stream is a ByteArrayOutputStream (such as with the no-parameter constructor), this will return the binary UTF8-encoded data that resulted from the character data written to this Writer.
`void` | `write(char[] ach)` Write an array of characters.
`void` | `write(char[] ach, int of, int cch)` Write a portion of an array of characters.
`void` | `write(int ch)` Write a single character.
`void` | `write(String s)` Write a string.
`void` | `write(String s, int of, int cch)` Write a portion of a string.

Methods inherited from class java.io.Writer
`append, append, append`

Constructor Detail

### Utf8Writer

    public Utf8Writer()

  Construct a Utf8Writer that buffers the output.

### Utf8Writer

    public Utf8Writer(OutputStream stream)

  Construct a Utf8Writer that puts the output into an OutputStream.
  Parameters:
    `stream` - the underlying stream to write to

Method Detail

### write

    public void write(int ch)
               throws IOException

  Write 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.

  Overrides:
    `write` in class `Writer`
  Parameters:
    `ch` - int specifying a character to be written.
  Throws:
    `IOException`

### write

    public void write(char[] ach)
               throws IOException

  Write an array of characters.
  Overrides:
    `write` in class `Writer`
  Parameters:
    `ach` - array of characters to write
  Throws:
    `IOException`

### write

    public void write(char[] ach,
                      int of,
                      int cch)
               throws IOException

  Write a portion of an array of characters.
  Specified by:
    `write` in class `Writer`
  Parameters:
    `ach` - array of characters to write from
    `of` - offset from which to start writing characters
    `cch` - number of characters to write
  Throws:
    `IOException`

### write

    public void write(String s)
               throws IOException

  Write a string.
  Overrides:
    `write` in class `Writer`
  Parameters:
    `s` - the String to write
  Throws:
    `IOException`

### write

    public void write(String s,
                      int of,
                      int cch)
               throws IOException

  Write a portion of a string.
  Overrides:
    `write` in class `Writer`
  Parameters:
    `s` - the String to write from
    `of` - offset from which to start writing characters
    `cch` - number of characters to write
  Throws:
    `IOException`

### flush

    public void flush()
               throws IOException

  Flush 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.
  Specified by:
    `flush` in interface `Flushable`
  Specified by:
    `flush` in class `Writer`
  Throws:
    `IOException` - If an I/O error occurs

### close

    public void close()
               throws IOException

  Close the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.
  Specified by:
    `close` in interface `Closeable`
  Specified by:
    `close` in class `Writer`
  Throws:
    `IOException` - If an I/O error occurs

### toByteArray

    public byte[] toByteArray()

  If the underlying stream is a ByteArrayOutputStream (such as with the no-parameter constructor), this will return the binary UTF8-encoded data that resulted from the character data written to this Writer.
  Returns:
    a byte array of the UTF8 data
  Throws:
    `ClassCastException` - if the underlying stream is not ByteArrayOutputStream

Skip navigation links

Overview | Package | Class | Tree | Index | Help
| Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.