Class LittleEndianDataInputStream

java.lang.Object
net.codecrete.windowsapi.winmd.LittleEndianDataInputStream

public class LittleEndianDataInputStream extends Object
A data input stream to read primitive Java data types in little-endian organization from an underlying input stream.

Similar to DataInputStream but uses little-endian instead of big-endian byte organization.

  • Constructor Details

    • LittleEndianDataInputStream

      public LittleEndianDataInputStream(InputStream in)
      Creates an instance using the specified underlying InputStream.
      Parameters:
      in - the specified input stream
  • Method Details

    • getOffset

      public long getOffset()
      Returns the current offset into the stream.
      Returns:
      offset, in bytes
    • readFully

      public final void readFully(byte[] b) throws IOException
      Reads data from the input.
      Parameters:
      b - the buffer into which the data is read.
      Throws:
      EOFException - if this input stream reaches the end before reading all the bytes.
      IOException - if another error occurs during reading
    • readFully

      public final void readFully(byte[] b, int off, int len) throws IOException
      Reads data from the input.
      Parameters:
      b - the buffer into which the data is read.
      off - the start offset in the data array b.
      len - the number of bytes to read.
      Throws:
      EOFException - if this input stream reaches the end before reading all the bytes.
      IOException - if another error occurs during reading
    • skipNBytes

      public void skipNBytes(int n) throws IOException
      Skips several bytes without further processing.
      Parameters:
      n - the number of bytes to skip
      Throws:
      IOException - thrown if an IO error occurs
    • skipTo

      public void skipTo(int offset) throws IOException
      Skips to the specified offset.
      Parameters:
      offset - number of bytes into the steam
      Throws:
      EOFException - if the offset is after the end of the stream
      IOException - if an I/O error occurs
    • readByte

      public final byte readByte() throws IOException
      Reads a byte
      Returns:
      the next byte of this input stream as a signed 8-bit byte.
      Throws:
      EOFException - if this input stream has reached the end.
      IOException - if any other I/O error occurs.
    • readUnsignedShort

      public final int readUnsignedShort() throws IOException
      Reads an unsigned 16-bit integer number.
      Returns:
      the next two bytes of this input stream, interpreted as an unsigned 16-bit integer.
      Throws:
      EOFException - if this input stream has reached the end.
      IOException - if any other I/O error occurs.
    • readInt

      public final int readInt() throws IOException
      Reads a signed 32-bit integer number.
      Returns:
      the next four bytes of this input stream, interpreted as an int.
      Throws:
      EOFException - if this input stream has reached the end.
      IOException - if any other I/O error occurs.
    • readLong

      public final long readLong() throws IOException
      Reads a signed 64-bit integer number.
      Returns:
      the next 8 bytes of this input stream, interpreted as an int.
      Throws:
      EOFException - if this input stream has reached the end.
      IOException - if any other I/O error occurs.