public class Utf8Writer extends Writer
| Constructor and Description |
|---|
Utf8Writer()
Construct a Utf8Writer that buffers the output.
|
Utf8Writer(OutputStream stream)
Construct a Utf8Writer that puts the output into an OutputStream.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
public Utf8Writer()
public Utf8Writer(OutputStream stream)
stream - the underlying stream to write to
public void write(int ch)
throws IOException
Subclasses that intend to support efficient single-character output should override this method.
write in class Writerch - int specifying a character to be written.IOException
public void write(char[] ach)
throws IOException
write in class Writerach - array of characters to writeIOException
public void write(char[] ach,
int of,
int cch)
throws IOException
write in class Writerach - array of characters to write fromof - offset from which to start writing characterscch - number of characters to writeIOExceptionpublic void write(String s) throws IOException
write in class Writers - the String to writeIOExceptionpublic void write(String s, int of, int cch) throws IOException
write in class Writers - the String to write fromof - offset from which to start writing characterscch - number of characters to writeIOException
public void flush()
throws IOException
flush in interface Flushableflush in class WriterIOException - If an I/O error occurs
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class WriterIOException - If an I/O error occurspublic byte[] toByteArray()
ClassCastException - if the underlying stream is not ByteArrayOutputStream