Package org.jboss.jandex
Class PackedDataOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- java.io.DataOutputStream
-
- org.jboss.jandex.PackedDataOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataOutput
,java.io.Flushable
,java.lang.AutoCloseable
class PackedDataOutputStream extends java.io.DataOutputStream
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.
-
-
Constructor Summary
Constructors Constructor Description PackedDataOutputStream(java.io.OutputStream out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
writePackedU32(int i)
Writes an unsigned integer in as few bytes as possible.-
Methods inherited from class java.io.DataOutputStream
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
-
-
-
Field Detail
-
MAX_1BYTE
static final int MAX_1BYTE
- See Also:
- Constant Field Values
-
MAX_2BYTE
static final int MAX_2BYTE
- See Also:
- Constant Field Values
-
MAX_3BYTE
static final int MAX_3BYTE
- See Also:
- Constant Field Values
-
MAX_4BYTE
static final int MAX_4BYTE
- See Also:
- Constant Field Values
-
-
Method Detail
-
writePackedU32
public void writePackedU32(int i) throws java.io.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
- the integer to pack and write- Throws:
java.io.IOException
- if any i/o error occurs
-
-