ByteArrayWriter
public class CharsetAdjustmentWriterDecorator extends java.lang.Object implements ByteArrayWriter
Unfortunately, String.getBytes()
can add a charset header (like a BOM for UTF-16) for every call.
Typically, file based writers call String.getBytes()
for each log entry. However, the charset header
should only be written only at the start of a log file and not for each log entry.
Constructor | Description |
---|---|
CharsetAdjustmentWriterDecorator(ByteArrayWriter writer,
byte[] charsetHeader) |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Closes this writer and releases any associated system resources.
|
void |
flush() |
Forces writing of any buffered data.
|
void |
write(byte[] data,
int length) |
Outputs a byte array.
|
void |
write(byte[] data,
int offset,
int length) |
Outputs a byte array.
|
public CharsetAdjustmentWriterDecorator(ByteArrayWriter writer, byte[] charsetHeader)
writer
- Underlying writercharsetHeader
- Charset header to skippublic void write(byte[] data, int length) throws java.io.IOException
ByteArrayWriter
write
in interface ByteArrayWriter
data
- Byte array to outputlength
- Number of bytes to outputjava.io.IOException
- Writing failedpublic void write(byte[] data, int offset, int length) throws java.io.IOException
ByteArrayWriter
write
in interface ByteArrayWriter
data
- Byte array to outputoffset
- Start offset to outputlength
- Number of bytes to outputjava.io.IOException
- Writing failedpublic void flush() throws java.io.IOException
ByteArrayWriter
flush
in interface ByteArrayWriter
java.io.IOException
- Writing failedpublic void close() throws java.io.IOException
ByteArrayWriter
close
in interface ByteArrayWriter
java.io.IOException
- Closing failedCopyright © 2021. All rights reserved.