org.gjt.convert.binhex
Class RLE_CRCInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--org.gjt.convert.binhex.RLE_CRCInputStream
- public class RLE_CRCInputStream
- extends java.io.FilterInputStream
Decodes Run-length encoding LE from a 8-bit BinHex stream and calculates
CRCs (Cyclic Redundancy Check) from the decoded bytes as it passes them to
the caller.
- Author:
- Erwin Bolwidt
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary |
RLE_CRCInputStream(java.io.InputStream source)
Constructs a RLE_CRCInputStream from a stream that is a source of 7-bit
Hqx7 encoded data. |
RLE_CRCInputStream(java.io.InputStream source,
boolean eightBit)
Constructs a RLE_CRCInputStream from a stream that is either a source
of 7-bit Hqx7 encoded data or of pure 8-bit data in Hqx8 format. |
Method Summary |
int |
getCRC()
Returns the CRC calculated over the data that was read since the beginning
of the stream or since the last call to resetCRC. |
static void |
main(java.lang.String[] args)
|
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
void |
resetCRC()
Resets the calculated CRC to zero. |
Methods inherited from class java.io.FilterInputStream |
available,
close,
mark,
markSupported,
reset,
skip |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
RLE_CRCInputStream
public RLE_CRCInputStream(java.io.InputStream source)
- Constructs a RLE_CRCInputStream from a stream that is a source of 7-bit
Hqx7 encoded data. This is the typical use for files fetched from the
Internet or through e-mail. Internally, a Hqx7_to_Hqx8InputStream is
created to translate from 7-bit to 8-bit format before passing the data
through this stream.
RLE_CRCInputStream
public RLE_CRCInputStream(java.io.InputStream source,
boolean eightBit)
- Constructs a RLE_CRCInputStream from a stream that is either a source
of 7-bit Hqx7 encoded data or of pure 8-bit data in Hqx8 format. The
flag eightBit tells this class what to expect.
- Parameters:
source
- the data sourceeightBit
- if true, the data source must supply 8-bit data in Hqx8 format.
If false, the data source must supply 7-bit data in Hqx7 format.
resetCRC
public void resetCRC()
- Resets the calculated CRC to zero. If your file contains multiple sections,
as the BinHex4 format does, you must reset it before switching to a new
section if you want to calculate CRCs for that section.
getCRC
public int getCRC()
- Returns the CRC calculated over the data that was read since the beginning
of the stream or since the last call to resetCRC.
Must only be called after all the data was read in a section, because
the CRC is updated as if two extra 0 bytes were read. This is dictated
by the BinHex4 protocol.
read
public int read()
throws java.io.IOException
- Overrides:
- read in class java.io.FilterInputStream
read
public int read(byte[] b)
throws java.io.IOException
- Overrides:
- read in class java.io.FilterInputStream
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Overrides:
- read in class java.io.FilterInputStream
main
public static void main(java.lang.String[] args)