Class LittleEndianByteInputStream

java.lang.Object
java.io.InputStream
com.webcodepro.shrinkit.io.LittleEndianByteInputStream
All Implemented Interfaces:
ByteConstants, Closeable, AutoCloseable

public class LittleEndianByteInputStream extends InputStream implements ByteConstants
A simple class to hide the source of byte data.
  • Constructor Details

    • LittleEndianByteInputStream

      public LittleEndianByteInputStream(InputStream inputStream)
      Construct a LittleEndianByteInputStream from an InputStream.
    • LittleEndianByteInputStream

      public LittleEndianByteInputStream(byte[] data)
      Construct a LittleEndianByteInputStream from a byte array.
  • Method Details

    • read

      public int read() throws IOException
      Get the next byte. Returns -1 if at end of input. Note that an unsigned byte needs to be returned in a larger container (ie, a short or int or long).
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • readByte

      public int readByte() throws IOException
      Get the next byte and fail if we are at EOF. Note that an unsigned byte needs to be returned in a larger container (ie, a short or int or long).
      Throws:
      IOException
    • readBytes

      public byte[] readBytes(int bytes) throws IOException
      Get the next set of bytes as an array. If EOF encountered, an IOException is thrown.
      Throws:
      IOException
    • seekFileType

      public int seekFileType() throws IOException
      Test the beginning of the data stream for a magic signature, for up to a total of 2k bytes of leading garbage
      Throws:
      IOException
    • seekFileType

      public int seekFileType(int max) throws IOException
      Test the beginning of the data stream for a magic signature, specifying the maximum size of a signature to test for
      Throws:
      IOException
    • readWord

      public int readWord() throws IOException
      Read the two bytes in as a "Word" which needs to be stored as a Java int.
      Throws:
      IOException
    • readLong

      public long readLong() throws IOException
      Read the two bytes in as a "Long" which needs to be stored as a Java long.
      Throws:
      IOException
    • readDate

      public Date readDate() throws IOException
      Read the TimeRec into a Java Date object. Note that years 00-39 are assumed to be 2000-2039 per the NuFX addendum.
      Throws:
      IOException
      See Also:
    • resetCrc

      public void resetCrc()
      Reset the CRC-16 to $0000.
    • getCrcValue

      public long getCrcValue()
      Get the current CRC-16 value.
    • getTotalBytesRead

      public long getTotalBytesRead()
      Answer with the total number of bytes read.