public abstract class BufferedMessageOutputStream extends MessageOutputStream
This OutputStream allows the replacement of the underlying stream and the serialisation of object through an internal ObjectOutputStream.
Be careful this OutputStream is not synchronized.
Modifier and Type | Field and Description |
---|---|
protected OutputStream |
out
The underlying output stream.
|
buf, compressedFlows, count, logmon, oos
Constructor and Description |
---|
BufferedMessageOutputStream()
Creates a new output stream to write data to an unspecified
underlying output stream through a buffer with default size.
|
BufferedMessageOutputStream(int size)
Creates a new output stream to write data to an unspecified
underlying output stream through a buffer with the specified size.
|
Modifier and Type | Method and Description |
---|---|
private void |
drain()
Writes the internal buffer in underlying output stream.
|
void |
flush()
Flushes this output stream.
|
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array
starting at offset off to this output stream. |
void |
write(int b)
Writes the specified byte to this output stream.
|
getLogger, write, writeHeader, writeInt, writeMessage, writeMessageHeader, writeShort
close
protected OutputStream out
public BufferedMessageOutputStream() throws IOException
IOException
- if the internal ObjectOutputStream cannot be
correctly initialized.public BufferedMessageOutputStream(int size) throws IOException
size
- the buffer size.IllegalArgumentException
- if size is less than 0.IOException
- if the internal ObjectOutputStream cannot be
correctly initialized.private final void drain() throws IOException
IOException
- an error occurs.public final void write(int b) throws IOException
write
in class MessageOutputStream
b
- the byte to be written.IOException
- if an I/O error occurs.public final void write(byte[] b, int off, int len) throws IOException
len
bytes from the specified byte array
starting at offset off
to this output stream.
Ordinarily this method stores bytes from the given array into this stream's buffer, flushing the buffer to the underlying output stream as needed. If the requested length is at least as large as this stream's buffer, however, then this method will flush the buffer and write the bytes directly to the underlying output stream.
write
in class MessageOutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.IOException
- if an I/O error occurs.public final void flush() throws IOException
This forces any buffered output bytes to be written out to the underlying output stream.
flush
in interface Flushable
flush
in class OutputStream
IOException
- if an I/O error occurs.Copyright © 2022 ScalAgent D.T.. All rights reserved.