public abstract class BufferedOutput extends OutputStream implements ObjectOutput
null
.
This class is not thread-safe.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buffer |
protected static byte[] |
EMPTY_BYTE_ARRAY |
protected int |
limit |
protected int |
position |
protected long |
totalPositionBase |
Modifier | Constructor and Description |
---|---|
protected |
BufferedOutput()
Creates new instance with empty buffer.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkEOB()
Throws
IllegalStateException if expression (position != limit) is true. |
protected abstract void |
needSpace()
This method is invoked when output methods need more space to write data.
|
long |
totalPosition()
Returns total position of this output stream.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
void |
writeAllFromChunkList(ChunkList chunks,
Object owner)
Writes all data from specified chunk list into this buffered output.
|
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeByteArray(byte[] bytes)
Writes an array of bytes in a compact encapsulation format.
|
void |
writeBytes(String str) |
void |
writeChar(int v) |
void |
writeChars(String str) |
void |
writeCompactInt(int v)
Writes an
int value in a compact format (see IOUtil ). |
void |
writeCompactLong(long v)
Writes a
long value in a compact format (see IOUtil ). |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeFromByteBuffer(ByteBuffer buffer)
Writes data from specified byte buffer into this buffered output.
|
void |
writeFromChunk(Chunk chunk,
Object owner)
Writes data from specified chunk into this buffered output.
|
void |
writeFromDataInput(DataInput in,
long length)
Writes data from specified data input into this buffered output.
|
long |
writeFromInputStream(InputStream in,
long length)
Writes data from specified input stream into this buffered output.
|
void |
writeInt(int v) |
void |
writeLong(long v) |
void |
writeMarshalled(Marshalled<?> marshalled)
Writes a
Marshalled object to a byte stream. |
void |
writeObject(Object obj)
Write an object to the underlying storage or stream in a compact encapsulation format
using
IOUtil.writeObject . |
void |
writeShort(int v) |
void |
writeUTF(String str) |
void |
writeUTFChar(int codePoint)
Writes a Unicode code point in a UTF-8 format.
|
void |
writeUTFString(String str)
Writes a string in a UTF-8 format with compact encapsulation (see
IOUtil ). |
close, flush
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, flush
protected static final byte[] EMPTY_BYTE_ARRAY
protected byte[] buffer
protected int position
protected int limit
protected long totalPositionBase
protected BufferedOutput()
protected abstract void needSpace() throws IOException
(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 and should maintain totalPositionBase
accordingly.IOException
- if an I/O error occursprotected final void checkEOB()
IllegalStateException
if expression (position != limit)
is true.public final long totalPosition()
public final void write(int b) throws IOException
write
in interface DataOutput
write
in interface ObjectOutput
write
in class OutputStream
IOException
public final void write(byte[] b) throws IOException
write
in interface DataOutput
write
in interface ObjectOutput
write
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 OutputStream
IOException
public final void writeBoolean(boolean v) throws IOException
writeBoolean
in interface DataOutput
IOException
public final void writeByte(int v) throws IOException
writeByte
in interface DataOutput
IOException
public final void writeShort(int v) throws IOException
writeShort
in interface DataOutput
IOException
public final void writeChar(int v) throws IOException
writeChar
in interface DataOutput
IOException
public final void writeInt(int v) throws IOException
writeInt
in interface DataOutput
IOException
public final void writeLong(long v) throws IOException
writeLong
in interface DataOutput
IOException
public final void writeFloat(float v) throws IOException
writeFloat
in interface DataOutput
IOException
public final void writeDouble(double v) throws IOException
writeDouble
in interface DataOutput
IOException
public final void writeBytes(String str) throws IOException
writeBytes
in interface DataOutput
IOException
public final void writeChars(String str) throws IOException
writeChars
in interface DataOutput
IOException
public final void writeUTF(String str) throws IOException
writeUTF
in interface DataOutput
IOException
public final void writeObject(Object obj) throws IOException
IOUtil.writeObject
.writeObject
in interface ObjectOutput
obj
- the object to be written.IOException
- if an I/O error occurspublic final void writeMarshalled(Marshalled<?> marshalled) throws IOException
Marshalled
object to a byte stream.
This method writes object length using
Marshaller.writeMarshalledLength
, followed
by the contents of the marshalled byte array.
When the serialization
marshaller
is used in marshalled object, then this method writes the same bytes as would have been been produced by
writeObject
method on the object repesentation
of the marshalled object. The corresponding bytes can be later read either using
or using BufferedInput.readMarshalled
(Marshaller.SERIALIZATION
)BufferedInput.readObject()
.
marshalled
- the marshalled object to be written.IOException
- if an I/O error occurspublic final void writeCompactInt(int v) throws IOException
int
value in a compact format (see IOUtil
).
Equivalent to IOUtil.writeCompactInt(java.io.DataOutput, int)
method.v
- the int
value to be writtenIOException
- if an I/O error occurspublic final void writeCompactLong(long v) throws IOException
long
value in a compact format (see IOUtil
).
Equivalent to IOUtil.writeCompactLong(java.io.DataOutput, long)
method.v
- the long
value to be writtenIOException
- if an I/O error occurspublic final void writeByteArray(byte[] bytes) throws IOException
IOUtil.writeByteArray(java.io.DataOutput, byte[])
method.bytes
- the byte array to be writtenIOException
- if an I/O error occurspublic final void writeUTFChar(int codePoint) throws IOException
IOUtil.writeUTFChar(java.io.DataOutput, int)
method.codePoint
- the code point to be writtenUTFDataFormatException
- if codePoint is not a valid Unicode characterIOException
- if an I/O error occurspublic final void writeUTFString(String str) throws IOException
IOUtil
).
Unpaired surrogate code points are accepted and written in a CESU-8 format.
This method defines length as a number of bytes.
Equivalent to IOUtil.writeUTFString(java.io.DataOutput, java.lang.String)
method.str
- the string to be writtenUTFDataFormatException
- if str is too longIOException
- if an I/O error occurspublic long writeFromInputStream(InputStream in, long length) throws IOException
in
- the source input stream to read fromlength
- maximum number of bytes to writeIOException
- if an I/O error occurspublic void writeFromDataInput(DataInput in, long length) throws IOException
in
- the source data input to read fromlength
- number of bytes to writeIOException
- if an I/O error occurspublic void writeFromByteBuffer(ByteBuffer buffer) throws IOException
buffer
- the source byte buffer to read fromIOException
- if an I/O error occurspublic void writeFromChunk(Chunk chunk, Object owner) throws IOException
read-only
.
A reference to the chunk is considered to become invalid after
invocation of this method and may no longer be used, unless the chunk was read-only.chunk
- the source chunk of bytesowner
- current owner of the chunkIllegalStateException
- if the chunk is not
read-only
and its current owner differs from the one specifiedIOException
- if an I/O error occurspublic void writeAllFromChunkList(ChunkList chunks, Object owner) throws IOException
read-only
.
A reference to the chunk list is considered to become invalid after
invocation of this method and may no longer be used, unless the chunk list was read-only.chunks
- the source chunk listowner
- current owner of the chunk listIllegalStateException
- if the chunk list is not
read-only
and its current owner differs from the one specifiedIOException
- if an I/O error occursCopyright © 2002–2025 Devexperts LLC. All rights reserved.