public final class Latin1AppendableOutputStream
extends java.io.OutputStream
java.io.OutputStream of Latin1 bytes onto an Appendable
sink. A modest buffer is used to batch up append operations.
In addition, the Appendable to be buffered is supplied using the
with(Appendable) method, rather than at construction time. This
allows the buffer to be reused for several different operations requiring
buffering.
Uses java.nio.CharBuffer.allocate() to create the backing buffer.
Does not propagate the flush() or close() methods
to the wrapped Appendable.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_SIZE
The default buffer size of 1024 characters, if none is specified.
|
| Constructor and Description |
|---|
Latin1AppendableOutputStream()
Adapt a given
Appendable with the default buffer size. |
Latin1AppendableOutputStream(int buffSize)
Adapt a given
Appendable with the given buffer size. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Flush and close the buffer of this
Latin1AppendableOutputStream. |
void |
flush()
Flush the buffer of this
Latin1AppendableOutputStream. |
Latin1AppendableOutputStream |
with(java.lang.Appendable newAppendable)
Reset this latin1 appendable, setting it to buffer the given
appendable.
|
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array
starting at offset off to the underlying Appendable
as Latin1 characters. |
void |
write(int b)
Writes the specified byte to the underlying
Appendable as a
Latin1 character. |
public static final int DEFAULT_BUFFER_SIZE
public Latin1AppendableOutputStream()
Appendable with the default buffer size.public Latin1AppendableOutputStream(int buffSize)
Appendable with the given buffer size.
The size must be at least 16.buffSize - the buffer size, must be >= 16java.lang.NullPointerException - the supplied Appendable is nullpublic Latin1AppendableOutputStream with(java.lang.Appendable newAppendable)
Appendable first.
This resets the state of the buffered reader to the open state
if the new appendable is non-null, otherwise resets the state to
closed.
newAppendable - the new Appendable to bufferLatin1AppendableOutputStreampublic void write(int b)
throws java.io.IOException
Appendable as a
Latin1 character.write in class java.io.OutputStreamb - the byte.java.io.IOException - if an I/O error occurs. In particular,
an IOException may be thrown if the
underlying Appendable has been closed.public void write(byte[] b,
int off,
int len)
throws java.io.IOException
len bytes from the specified byte array
starting at offset off to the underlying Appendable
as Latin1 characters.
If b is null, a NullPointerException is thrown.
If off is negative, or len is negative, or
off+len is greater than the length of the array
b, then an IndexOutOfBoundsException is thrown.
write in class java.io.OutputStreamb - the data.off - the start offset in the data.len - the number of bytes to write.java.io.IOException - if an I/O error occurs. In particular,
an IOException is thrown if the underlying
Appendable is closed.public void flush()
throws java.io.IOException
Latin1AppendableOutputStream.flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOException - there was a problem appending to the underlying
Appendablepublic void close()
throws java.io.IOException
Latin1AppendableOutputStream.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.OutputStreamjava.io.IOException - there was a problem appending to the underlying
Appendable