public final class UTF8StreamWriter
extends java.io.Writer
Constructor and Description |
---|
UTF8StreamWriter()
Creates a UTF-8 writer having a byte buffer of moderate capacity (2048).
|
UTF8StreamWriter(int capacity)
Creates a UTF-8 writer having a byte buffer of specified capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes and
resets this writer for reuse. |
void |
flush()
Flushes the stream.
|
void |
reset() |
UTF8StreamWriter |
setOutput(java.io.OutputStream out)
Sets the output stream to use for writing until this writer is closed.
|
UTF8StreamWriter |
setOutputStream(java.io.OutputStream out)
Deprecated.
Replaced by
setOutput(OutputStream) |
void |
write(char c)
Writes a single character.
|
void |
write(char[] cbuf,
int off,
int len)
Writes a portion of an array of characters.
|
void |
write(java.lang.CharSequence csq)
Writes the specified character sequence.
|
void |
write(int code)
Writes a character given its 31-bits Unicode.
|
void |
write(java.lang.String str,
int off,
int len)
Writes a portion of a string.
|
public UTF8StreamWriter()
public UTF8StreamWriter(int capacity)
capacity
- the capacity of the byte buffer.public UTF8StreamWriter setOutput(java.io.OutputStream out)
public void write(char c) throws java.io.IOException
c
- char
the character to be written (possibly
a surrogate).java.io.IOException
- if an I/O error occurs.public void write(int code) throws java.io.IOException
write
in class java.io.Writer
code
- the 31 bits Unicode of the character to be written.java.io.IOException
- if an I/O error occurs.public void write(char[] cbuf, int off, int len) throws java.io.IOException
write
in class java.io.Writer
cbuf
- the array of characters.off
- the offset from which to start writing characters.len
- the number of characters to write.java.io.IOException
- if an I/O error occurs.public void write(java.lang.String str, int off, int len) throws java.io.IOException
write
in class java.io.Writer
str
- a String.off
- the offset from which to start writing characters.len
- the number of characters to write.java.io.IOException
- if an I/O error occurspublic void write(java.lang.CharSequence csq) throws java.io.IOException
csq
- the character sequence.java.io.IOException
- if an I/O error occurspublic void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.Writer
java.io.IOException
- if an I/O error occurs.public void close() throws java.io.IOException
resets
this writer for reuse.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Writer
java.io.IOException
- if an I/O error occurspublic void reset()
@Deprecated public UTF8StreamWriter setOutputStream(java.io.OutputStream out)
setOutput(OutputStream)