Class ByteBitInputStream
java.lang.Object
net.sourceforge.plantuml.code.deflate.ByteBitInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,BitInputStream
A stream of bits that can be read. Because they come from an underlying byte
stream, the total number of bits is always a multiple of 8. The bits are read
in little endian. Mutable and not thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a bit input stream based on the specified byte input stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this stream and the underlying input stream.intReturns the current bit position, which ascends from 0 to 7 as bits are read.intread()Reads a bit from this stream.intreadByte()Discards the remainder of the current byte (if any) and reads the next whole byte from the stream.intReads a bit from this stream.
-
Constructor Details
-
ByteBitInputStream
Constructs a bit input stream based on the specified byte input stream.- Parameters:
in- the byte input stream (notnull)- Throws:
NullPointerException- if the input stream isnull
-
-
Method Details
-
getBitPosition
public int getBitPosition()Description copied from interface:BitInputStreamReturns the current bit position, which ascends from 0 to 7 as bits are read.- Specified by:
getBitPositionin interfaceBitInputStream- Returns:
- the current bit position, which is between 0 and 7
-
readByte
Description copied from interface:BitInputStreamDiscards the remainder of the current byte (if any) and reads the next whole byte from the stream. Returns -1 if the end of stream is reached.- Specified by:
readBytein interfaceBitInputStream- Returns:
- the next byte from the stream, or -1 if the end of stream is reached
- Throws:
IOException
-
read
Description copied from interface:BitInputStreamReads a bit from this stream. Returns 0 or 1 if a bit is available, or -1 if the end of stream is reached. The end of stream always occurs on a byte boundary.- Specified by:
readin interfaceBitInputStream- Returns:
- the next bit of 0 or 1, or -1 for the end of stream
- Throws:
IOException- if an I/O exception occurred
-
readNoEof
Description copied from interface:BitInputStreamReads a bit from this stream. Returns 0 or 1 if a bit is available, or throws anEOFExceptionif the end of stream is reached. The end of stream always occurs on a byte boundary.- Specified by:
readNoEofin interfaceBitInputStream- Returns:
- the next bit of 0 or 1
- Throws:
IOException- if an I/O exception occurredEOFException- if the end of stream is reached
-
close
Description copied from interface:BitInputStreamCloses this stream and the underlying input stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBitInputStream- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O exception occurred
-