Package totalcross.json.zip
Class BitOutputStream
- java.lang.Object
-
- totalcross.json.zip.BitOutputStream
-
-
Constructor Summary
Constructors Constructor Description BitOutputStream(Stream out)Use an OutputStream to produce a BitWriter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longnrBits()Returns the number of bits that have been written to this bitOutputStream.voidone()Write a 1 bit.voidpad(int width)Pad the rest of the block with zeros and flush.voidwrite(int bits, int width)Write some bits.voidzero()Write a 0 bit.
-
-
-
Constructor Detail
-
BitOutputStream
public BitOutputStream(Stream out)
Use an OutputStream to produce a BitWriter. The BitWriter will send its bits to the OutputStream as each byte is filled.- Parameters:
out- An Output Stream
-
-
Method Detail
-
nrBits
public long nrBits()
Returns the number of bits that have been written to this bitOutputStream. This may include bits that have not yet been written to the underlying outputStream.
-
one
public void one() throws IOExceptionWrite a 1 bit.- Specified by:
onein interfaceBitWriter- Throws:
IOException
-
pad
public void pad(int width) throws IOExceptionPad the rest of the block with zeros and flush. pad(8) flushes the last unfinished byte. The underlying OutputStream will be flushed.- Specified by:
padin interfaceBitWriter- Parameters:
width- The size of the block to pad in bits. This will typically be 8, 16, 32, 64, 128, 256, etc.- Throws:
IOException
-
write
public void write(int bits, int width) throws IOExceptionWrite some bits. Up to 32 bits can be written at a time.- Specified by:
writein interfaceBitWriter- Parameters:
bits- The bits to be written.width- The number of bits to write. (0..32)- Throws:
IOException
-
zero
public void zero() throws IOExceptionWrite a 0 bit.- Specified by:
zeroin interfaceBitWriter- Throws:
IOException
-
-