public class StreamOutput extends BufferedOutput
BufferedOutput
that writes all data to destination OutputStream
.Modifier and Type | Field and Description |
---|---|
protected OutputStream |
out |
buffer, EMPTY_BYTE_ARRAY, limit, position
Constructor and Description |
---|
StreamOutput()
Creates a new stream output with default buffer capacity.
|
StreamOutput(int size)
Creates a new stream output with specified buffer capacity.
|
StreamOutput(OutputStream out)
Creates a new stream output with specified destination output stream and default buffer capacity.
|
StreamOutput(OutputStream out,
int size)
Creates a new stream output with specified destination output stream and buffer capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
protected void |
needSpace()
This method is invoked when output methods need more space to write data.
|
void |
resetOutput()
Resets this stream output by releasing destination output stream and resetting position.
|
void |
setOutput(OutputStream out)
Sets new destination output stream.
|
void |
write(byte[] b,
int off,
int len) |
write, write, writeBoolean, writeByte, writeByteArray, writeBytes, writeChar, writeChars, writeCompactInt, writeCompactLong, writeDouble, writeFloat, writeInt, writeLong, writeObject, writeShort, writeUTF, writeUTFChar, writeUTFString
protected OutputStream out
public StreamOutput()
public StreamOutput(int size)
size
- the initial buffer sizeIllegalArgumentException
- if size is not positivepublic StreamOutput(OutputStream out)
out
- the destination to write topublic StreamOutput(OutputStream out, int size)
out
- the destination to write tosize
- the initial buffer sizeIllegalArgumentException
- if size is not positivepublic void setOutput(OutputStream out)
null
to release destination.out
- the destination to write topublic void resetOutput()
public void flush() throws IOException
flush
in interface Flushable
flush
in interface ObjectOutput
flush
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface ObjectOutput
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in interface DataOutput
write
in interface ObjectOutput
write
in class BufferedOutput
IOException
protected void needSpace() throws IOException
BufferedOutput
(position < limit)
is true or throw an exception. This method may block if needed.
This method is allowed to update buffer, position and limit fields as needed.needSpace
in class BufferedOutput
IOException
- if an I/O error occursCopyright © 2014 Devexperts. All Rights Reserved.