Top Description Fields Constructors Methods
org.jboss.jandex

pack-priv Class PackedDataOutputStream

extends DataOutputStream
Class Inheritance
Imports
java.io.DataOutputStream, .IOException, .OutputStream

An output stream that can pack integers into as few bytes as possible. PackedDataOutputStream

Thread-Safety

This class is not thread-safe can not be shared between threads.
Author
Jason T. Greene

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
Inherited from java.io.DataOutputStream:
written

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
writePackedU32(int
the integer to pack and write
i
)

Writes an unsigned integer in as few bytes as possible.

Inherited from java.io.DataOutputStream:
flushsizewritewritewriteBooleanwriteBytewriteByteswriteCharwriteCharswriteDoublewriteFloatwriteIntwriteLongwriteShortwriteUTF

Field Detail

MAX_1BYTEback to summary
pack-priv static final int MAX_1BYTE
MAX_2BYTEback to summary
pack-priv static final int MAX_2BYTE
MAX_3BYTEback to summary
pack-priv static final int MAX_3BYTE
MAX_4BYTEback to summary
pack-priv static final int MAX_4BYTE

Constructor Detail

PackedDataOutputStreamback to summary
public PackedDataOutputStream(OutputStream out)

Method Detail

writePackedU32back to summary
public void writePackedU32(int i) throws IOException

Writes an unsigned integer in as few bytes as possible. Every byte uses the first bit as a control bit to signal when there are additional bytes to be read on the receiving end. The remaining seven bits are data. Depending on the size of the number one to five bytes may be written. The bytes are written in network-order (big endian)

Note that a signed integer can still be used, but due to two's compliment, all negative values will be written as five bytes

Parameters
i:int

the integer to pack and write

Exceptions
IOException:
if any i/o error occurs