ByteArrayWriter
public final class BufferedWriterDecorator extends java.lang.Object implements ByteArrayWriter
ByteArrayWriter
implementation. Data will be finally written if
either the buffer is full or flush()
or close()
is called.Constructor | Description |
---|---|
BufferedWriterDecorator(ByteArrayWriter writer) |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Closes this writer and releases any associated system resources.
|
void |
flush() |
Forces writing of any buffered data.
|
int |
readTail(byte[] data,
int offset,
int length) |
Reads the last bytes.
|
void |
truncate(int count) |
Truncates the file size.
|
void |
write(byte[] data,
int length) |
Outputs a byte array.
|
void |
write(byte[] data,
int offset,
int length) |
Outputs a byte array.
|
public BufferedWriterDecorator(ByteArrayWriter writer)
writer
- Underlying writerpublic int readTail(byte[] data, int offset, int length) throws java.io.IOException
ByteArrayWriter
The bytes are read from the end of the current file. If the file size is equal to or greater than the passed length, the passed array is filled completely. Otherwise, the passed array is filled with the entire available file content and all remaining bytes of the array are left untouched.
readTail
in interface ByteArrayWriter
data
- Target byte array for storing the read bytesoffset
- Start offset to fill passed byte arraylength
- Maximum number of bytes to readjava.io.IOException
- Reading failedpublic 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 truncate(int count) throws java.io.IOException
ByteArrayWriter
truncate
in interface ByteArrayWriter
count
- Number of bytes to remove from the file endjava.io.IOException
- Resizing 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 © 2022. All rights reserved.