Class LittleEndianDataInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public final class LittleEndianDataInputStream
    extends InputStream
    Based on DataInputStream but little endian and without the String/char methods
    • Constructor Detail

      • LittleEndianDataInputStream

        public LittleEndianDataInputStream​(InputStream in)
        Creates a LittleEndianDataInputStream that uses the specified underlying InputStream.
        Parameters:
        in - the specified input stream
    • Method Detail

      • readFully

        public final void readFully​(byte[] b)
                             throws IOException
        See the general contract of the readFully method of DataInput.

        Bytes for this operation are read from the contained input stream.

        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 - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        FilterInputStream.in
      • readFully

        public final void readFully​(byte[] b,
                                    int off,
                                    int len)
                             throws IOException
        See the general contract of the readFully method of DataInput.

        Bytes for this operation are read from the contained input stream.

        Parameters:
        b - the buffer into which the data is read.
        off - the start offset of the data.
        len - the number of bytes to read.
        Throws:
        EOFException - if this input stream reaches the end before reading all the bytes.
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        FilterInputStream.in
      • skipBytes

        public final int skipBytes​(int n)
                            throws IOException
        See the general contract of the skipBytes method of DataInput.

        Bytes for this operation are read from the contained input stream.

        Parameters:
        n - the number of bytes to be skipped.
        Returns:
        the actual number of bytes skipped.
        Throws:
        IOException - if the contained input stream does not support seek, or the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
      • mark

        public void mark​(int readlimit)
        Overrides:
        mark in class InputStream
        Parameters:
        readlimit - the number of bytes the mark will be valid for
        See Also:
        InputStream.mark(int)
      • readBoolean

        public final boolean readBoolean()
                                  throws IOException
        See the general contract of the readBoolean method of DataInput.

        Bytes for this operation are read from the contained input stream.

        Returns:
        the boolean value read.
        Throws:
        EOFException - if this input stream has reached the end.
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        FilterInputStream.in
      • readByte

        public final byte readByte()
                            throws IOException
        See the general contract of the readByte method of DataInput.

        Bytes for this operation are read from the contained input stream.

        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 - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        FilterInputStream.in
      • readUnsignedByte

        public final int readUnsignedByte()
                                   throws IOException
        See the general contract of the readUnsignedByte method of DataInput.

        Bytes for this operation are read from the contained input stream.

        Returns:
        the next byte of this input stream, interpreted as an unsigned 8-bit number.
        Throws:
        EOFException - if this input stream has reached the end.
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        FilterInputStream.in
      • readShort

        public final short readShort()
                              throws IOException
        Bytes for this operation are read from the contained input stream.
        Returns:
        the next two bytes of this input stream, interpreted as a signed 16-bit number.
        Throws:
        EOFException - if this input stream reaches the end before reading two bytes.
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        FilterInputStream.in
      • readUnsignedShort

        public final int readUnsignedShort()
                                    throws IOException
        Bytes for this operation are read from the contained input stream.
        Returns:
        the next two bytes of this input stream, interpreted as an unsigned 16-bit integer.
        Throws:
        EOFException - if this input stream reaches the end before reading two bytes.
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        FilterInputStream.in
      • readInt

        public final int readInt()
                          throws IOException
        Bytes for this operation are read from the contained input stream.
        Returns:
        the next four bytes of this input stream, interpreted as an int.
        Throws:
        EOFException - if this input stream reaches the end before reading four bytes.
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        FilterInputStream.in
      • readLong

        public final long readLong()
                            throws IOException
        Bytes for this operation are read from the contained input stream.
        Returns:
        the next eight bytes of this input stream, interpreted as a long.
        Throws:
        EOFException - if this input stream reaches the end before reading eight bytes.
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        FilterInputStream.in
      • readFloat

        public final float readFloat()
                              throws IOException
        Bytes for this operation are read from the contained input stream.
        Returns:
        the next four bytes of this input stream, interpreted as a float.
        Throws:
        EOFException - if this input stream reaches the end before reading four bytes.
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        Float.intBitsToFloat(int)
      • readDouble

        public final double readDouble()
                                throws IOException
        Bytes for this operation are read from the contained input stream.
        Returns:
        the next eight bytes of this input stream, interpreted as a double.
        Throws:
        EOFException - if this input stream reaches the end before reading eight bytes.
        IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
        See Also:
        Double.longBitsToDouble(long)