Class ASCIIHexInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
The ASCIIHexDecode filter shall produce one byte of binary data for each pair of ASCII hexadecimal digits (0–9 and
A–F or a–f). All white-space characters (see 7.2, "Lexical conventions") shall be ignored. A GREATER-THAN SIGN (3Eh)
indicates EOD (End Of Data). Any other characters shall cause an error.
If the filter encounters the EOD marker after reading an odd number of hexadecimal digits, it shall behave as if a
0 (zero) followed the last digit.
- PDF Spec ISO 32000-2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.intread()Reads the next byte of data from the input stream.intread(byte[] outputBuffer, int outputOffset, int byteCount) Reads up to len bytes of data from this input stream into an array of bytes.longskip(long n) Skips over and discards n bytes of data from the input stream.Methods inherited from class java.io.FilterInputStream
close, mark, markSupported, read, resetMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
ASCIIHexInputStream
-
-
Method Details
-
read
Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown- Overrides:
readin classFilterInputStream- Returns:
- the next byte of data, or -1 if the end of the stream is reached.
- Throws:
IOException- if an IO error occurs
-
read
Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.- Overrides:
readin classFilterInputStream- Parameters:
outputBuffer- the buffer into which the data is read.outputOffset- the start offset in arrayoutputBytesat which the data is written.byteCount- the maximum number of bytes to read.- Returns:
- the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
- Throws:
IOException- if an IO error occurs- Implementation Note:
- This method will retroactively notice the closing
>before stopping just before. That means it will likely overrun this byte in the underlying InputStream with the assumption that it will be closed with this input stream.
-
skip
Skips over and discards n bytes of data from the input stream.The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.
Due to hex being 2 characters per byte, this method will skip twice as many bytes as requested from the underlying stream. The method will also ignore garbage in the underlying stream and only count valid hex whilst skipping.
- Overrides:
skipin classFilterInputStream- Parameters:
n- the number of bytes to be skipped.- Returns:
- the actual number of bytes skipped
- Throws:
IOException- if an io error occurs
-
available
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.The result will be half the bytes available in the underlying InputStream due to 2 hex characters making one byte. Fewer bytes may actually be available as this does not account for garbage in the underlying stream.
- Overrides:
availablein classFilterInputStream- Returns:
- an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking.
- Throws:
IOException- if an I/O error occurs
-