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
public class SwappedDataInputStream extends ProxyInputStream implements DataInput
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.Origin of code: Avalon Excalibur (IO)
-
-
Constructor Summary
Constructors Constructor Description SwappedDataInputStream(InputStream input)Constructs a SwappedDataInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanreadBoolean()ReturnreadByte()!= 0bytereadByte()Invokes the delegate'sread()method.charreadChar()Reads a character delegating toreadShort().doublereadDouble()Delegates toEndianUtils.readSwappedDouble(InputStream).floatreadFloat()Delegates toEndianUtils.readSwappedFloat(InputStream).voidreadFully(byte[] data)Invokes the delegate'sread(byte[] data, int, int)method.voidreadFully(byte[] data, int offset, int length)Invokes the delegate'sread(byte[] data, int, int)method.intreadInt()Delegates toEndianUtils.readSwappedInteger(InputStream).StringreadLine()Not currently supported - throwsUnsupportedOperationException.longreadLong()Delegates toEndianUtils.readSwappedLong(InputStream).shortreadShort()Delegates toEndianUtils.readSwappedShort(InputStream).intreadUnsignedByte()Invokes the delegate'sread()method.intreadUnsignedShort()Delegates toEndianUtils.readSwappedUnsignedShort(InputStream).StringreadUTF()Not currently supported - throwsUnsupportedOperationException.intskipBytes(int count)Invokes the delegate'sskip(int)method.-
Methods inherited from class org.apache.commons.io.input.ProxyInputStream
available, close, mark, markSupported, read, read, read, reset, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
SwappedDataInputStream
public SwappedDataInputStream(InputStream input)
Constructs a SwappedDataInputStream.- Parameters:
input- InputStream to read from
-
-
Method Detail
-
readBoolean
public boolean readBoolean() throws IOException, EOFExceptionReturnreadByte()!= 0- Specified by:
readBooleanin 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
public byte readByte() throws IOException, EOFExceptionInvokes the delegate'sread()method.- Specified by:
readBytein 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
public char readChar() throws IOException, EOFExceptionReads a character delegating toreadShort().- Specified by:
readCharin 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
-
readDouble
public double readDouble() throws IOException, EOFExceptionDelegates toEndianUtils.readSwappedDouble(InputStream).- Specified by:
readDoublein interfaceDataInput- Returns:
- the read long
- Throws:
IOException- if an I/O error occurs.EOFException- if an end of file is reached unexpectedly
-
readFloat
public float readFloat() throws IOException, EOFExceptionDelegates toEndianUtils.readSwappedFloat(InputStream).- Specified by:
readFloatin interfaceDataInput- Returns:
- the read long
- Throws:
IOException- if an I/O error occurs.EOFException- if an end of file is reached unexpectedly
-
readFully
public void readFully(byte[] data) throws IOException, EOFExceptionInvokes the delegate'sread(byte[] data, int, int)method.- Specified by:
readFullyin 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
public void readFully(byte[] data, int offset, int length) throws IOException, EOFExceptionInvokes the delegate'sread(byte[] data, int, int)method.- Specified by:
readFullyin 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
public int readInt() throws IOException, EOFExceptionDelegates toEndianUtils.readSwappedInteger(InputStream).- Specified by:
readIntin interfaceDataInput- Returns:
- the read long
- Throws:
EOFException- if an end of file is reached unexpectedlyIOException- if an I/O error occurs.
-
readLine
public String readLine() throws IOException, EOFException
Not currently supported - throwsUnsupportedOperationException.- Specified by:
readLinein interfaceDataInput- Returns:
- the line read
- Throws:
EOFException- if an end of file is reached unexpectedlyIOException- if an I/O error occurs.
-
readLong
public long readLong() throws IOException, EOFExceptionDelegates toEndianUtils.readSwappedLong(InputStream).- Specified by:
readLongin interfaceDataInput- Returns:
- the read long
- Throws:
EOFException- if an end of file is reached unexpectedlyIOException- if an I/O error occurs.
-
readShort
public short readShort() throws IOException, EOFExceptionDelegates toEndianUtils.readSwappedShort(InputStream).- Specified by:
readShortin interfaceDataInput- Returns:
- the read long
- Throws:
EOFException- if an end of file is reached unexpectedlyIOException- if an I/O error occurs.
-
readUnsignedByte
public int readUnsignedByte() throws IOException, EOFExceptionInvokes the delegate'sread()method.- Specified by:
readUnsignedBytein 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
public int readUnsignedShort() throws IOException, EOFExceptionDelegates toEndianUtils.readSwappedUnsignedShort(InputStream).- Specified by:
readUnsignedShortin interfaceDataInput- Returns:
- the read long
- Throws:
EOFException- if an end of file is reached unexpectedlyIOException- if an I/O error occurs.
-
readUTF
public String readUTF() throws IOException, EOFException
Not currently supported - throwsUnsupportedOperationException.- Specified by:
readUTFin interfaceDataInput- Returns:
- UTF String read
- Throws:
EOFException- if an end of file is reached unexpectedlyIOException- if an I/O error occurs.
-
skipBytes
public int skipBytes(int count) throws IOException, EOFExceptionInvokes the delegate'sskip(int)method.- Specified by:
skipBytesin interfaceDataInput- Parameters:
count- the number of bytes to skip- Returns:
- the number of bytes to skipped or -1 if the end of stream
- Throws:
EOFException- if an end of file is reached unexpectedlyIOException- if an I/O error occurs.
-
-