Package org.apache.commons.io.input
Class SwappedDataInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.commons.io.input.ProxyInputStream
org.apache.commons.io.input.SwappedDataInputStream
- All Implemented Interfaces:
Closeable
,DataInput
,AutoCloseable
DataInput for systems relying on little-endian data formats. When read, values will be changed from little-endian to
big-endian formats for internal usage.
Provenance: Avalon Excalibur (IO)
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.io.input.ProxyInputStream
ProxyInputStream.AbstractBuilder<T,
B extends AbstractStreamBuilder<T, B>> -
Field Summary
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorDescriptionConstructs a SwappedDataInputStream. -
Method Summary
Modifier and TypeMethodDescriptionboolean
ReturnreadByte()
!byte
readByte()
Invokes the delegate'sread()
method.char
readChar()
Reads a 2 byte, unsigned, little endian UTF-16 code point.double
Reads an 8 byte, two's complement, little-endian long.float
Reads a 4 byte, IEEE 754, little-endian float.void
readFully
(byte[] data) Invokes the delegate'sread(byte[] data, int, int)
method.void
readFully
(byte[] data, int offset, int length) Invokes the delegate'sread(byte[] data, int, int)
method.int
readInt()
Reads a 4 byte, two's complement little-endian integer.readLine()
Not currently supported - throwsUnsupportedOperationException
.long
readLong()
Reads an 8 byte, two's complement little-endian integer.short
Reads a 2 byte, two's complement, little-endian integer.int
Invokes the delegate'sread()
method.int
Reads a 2 byte, unsigned, little-endian integer.readUTF()
Not currently supported - throwsUnsupportedOperationException
.int
skipBytes
(int count) Invokes the delegate'sskip(int)
method.Methods inherited from class org.apache.commons.io.input.ProxyInputStream
afterRead, available, beforeRead, close, handleIOException, mark, markSupported, read, read, read, reset, skip, unwrap
-
Constructor Details
-
SwappedDataInputStream
Constructs a SwappedDataInputStream.- Parameters:
input
- InputStream to read from
-
-
Method Details
-
readBoolean
ReturnreadByte()
!= 0- Specified by:
readBoolean
in interfaceDataInput
- Returns:
- false if the byte read is zero, otherwise true
- Throws:
IOException
- if an I/O error occurs.EOFException
- if an end of file is reached unexpectedly
-
readByte
Invokes the delegate'sread()
method.- Specified by:
readByte
in interfaceDataInput
- Returns:
- the byte read or -1 if the end of stream
- Throws:
IOException
- if an I/O error occurs.EOFException
- if an end of file is reached unexpectedly
-
readChar
Reads a 2 byte, unsigned, little endian UTF-16 code point.- Specified by:
readChar
in interfaceDataInput
- Returns:
- the UTF-16 code point read or -1 if the end of stream
- Throws:
IOException
- if an I/O error occurs.EOFException
- if an end of file is reached unexpectedly
-
readDouble
Reads an 8 byte, two's complement, little-endian long.- Specified by:
readDouble
in interfaceDataInput
- Returns:
- the read long
- Throws:
IOException
- if an I/O error occurs.EOFException
- if an end of file is reached unexpectedly
-
readFloat
Reads a 4 byte, IEEE 754, little-endian float.- Specified by:
readFloat
in interfaceDataInput
- Returns:
- the read float
- Throws:
IOException
- if an I/O error occurs.EOFException
- if an end of file is reached unexpectedly
-
readFully
Invokes the delegate'sread(byte[] data, int, int)
method.- Specified by:
readFully
in interfaceDataInput
- Parameters:
data
- the buffer to read the bytes into- Throws:
EOFException
- if an end of file is reached unexpectedlyIOException
- if an I/O error occurs.
-
readFully
Invokes the delegate'sread(byte[] data, int, int)
method.- Specified by:
readFully
in interfaceDataInput
- Parameters:
data
- the buffer to read the bytes intooffset
- The start offsetlength
- The number of bytes to read- Throws:
EOFException
- if an end of file is reached unexpectedlyIOException
- if an I/O error occurs.
-
readInt
Reads a 4 byte, two's complement little-endian integer.- Specified by:
readInt
in interfaceDataInput
- Returns:
- the read int
- Throws:
EOFException
- if an end of file is reached unexpectedlyIOException
- if an I/O error occurs.
-
readLine
Not currently supported - throwsUnsupportedOperationException
.- Specified by:
readLine
in interfaceDataInput
- Returns:
- the line read
- Throws:
EOFException
- if an end of file is reached unexpectedlyIOException
- if an I/O error occursUnsupportedOperationException
- always
-
readLong
Reads an 8 byte, two's complement little-endian integer.- Specified by:
readLong
in interfaceDataInput
- Returns:
- the read long
- Throws:
EOFException
- if an end of file is reached unexpectedlyIOException
- if an I/O error occurs.
-
readShort
Reads a 2 byte, two's complement, little-endian integer.- Specified by:
readShort
in interfaceDataInput
- Returns:
- the read short
- Throws:
EOFException
- if an end of file is reached unexpectedlyIOException
- if an I/O error occurs.
-
readUnsignedByte
Invokes the delegate'sread()
method.- Specified by:
readUnsignedByte
in interfaceDataInput
- Returns:
- the byte read or -1 if the end of stream
- Throws:
EOFException
- if an end of file is reached unexpectedlyIOException
- if an I/O error occurs.
-
readUnsignedShort
Reads a 2 byte, unsigned, little-endian integer.- Specified by:
readUnsignedShort
in interfaceDataInput
- Returns:
- the read short
- Throws:
EOFException
- if an end of file is reached unexpectedlyIOException
- if an I/O error occurs.
-
readUTF
Not currently supported - throwsUnsupportedOperationException
.- Specified by:
readUTF
in interfaceDataInput
- Returns:
- never
- Throws:
EOFException
- if an end of file is reached unexpectedlyIOException
- if an I/O error occursUnsupportedOperationException
- always
-
skipBytes
Invokes the delegate'sskip(int)
method.- Specified by:
skipBytes
in interfaceDataInput
- Parameters:
count
- the number of bytes to skip- Returns:
- the number of bytes skipped or -1 if the end of stream
- Throws:
IOException
- if an I/O error occurs
-