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:
 java.io.Closeable,java.io.DataInput,java.lang.AutoCloseable
public class SwappedDataInputStream extends ProxyInputStream implements java.io.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.Provenance: Avalon Excalibur (IO)
 
- 
- 
Constructor Summary
Constructors Constructor Description SwappedDataInputStream(java.io.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 2 byte, unsigned, little endian UTF-16 code point.doublereadDouble()Reads an 8 byte, two's complement, little-endian long.floatreadFloat()Reads a 4 byte, IEEE 754, little-endian float.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()Reads a 4 byte, two's complement little-endian integer.java.lang.StringreadLine()Not currently supported - throwsUnsupportedOperationException.longreadLong()Reads an 8 byte, two's complement little-endian integer.shortreadShort()Reads a 2 byte, two's complement, little-endian integer.intreadUnsignedByte()Invokes the delegate'sread()method.intreadUnsignedShort()Reads a 2 byte, unsigned, little-endian integer.java.lang.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, unwrap 
 - 
 
 - 
 
- 
- 
Method Detail
- 
readBoolean
public boolean readBoolean() throws java.io.IOException, java.io.EOFExceptionReturnreadByte()!= 0- Specified by:
 readBooleanin interfacejava.io.DataInput- Returns:
 - false if the byte read is zero, otherwise true
 - Throws:
 java.io.IOException- if an I/O error occurs.java.io.EOFException- if an end of file is reached unexpectedly
 
- 
readByte
public byte readByte() throws java.io.IOException, java.io.EOFExceptionInvokes the delegate'sread()method.- Specified by:
 readBytein interfacejava.io.DataInput- Returns:
 - the byte read or -1 if the end of stream
 - Throws:
 java.io.IOException- if an I/O error occurs.java.io.EOFException- if an end of file is reached unexpectedly
 
- 
readChar
public char readChar() throws java.io.IOException, java.io.EOFExceptionReads a 2 byte, unsigned, little endian UTF-16 code point.- Specified by:
 readCharin interfacejava.io.DataInput- Returns:
 - the UTF-16 code point read or -1 if the end of stream
 - Throws:
 java.io.IOException- if an I/O error occurs.java.io.EOFException- if an end of file is reached unexpectedly
 
- 
readDouble
public double readDouble() throws java.io.IOException, java.io.EOFExceptionReads an 8 byte, two's complement, little-endian long.- Specified by:
 readDoublein interfacejava.io.DataInput- Returns:
 - the read long
 - Throws:
 java.io.IOException- if an I/O error occurs.java.io.EOFException- if an end of file is reached unexpectedly
 
- 
readFloat
public float readFloat() throws java.io.IOException, java.io.EOFExceptionReads a 4 byte, IEEE 754, little-endian float.- Specified by:
 readFloatin interfacejava.io.DataInput- Returns:
 - the read float
 - Throws:
 java.io.IOException- if an I/O error occurs.java.io.EOFException- if an end of file is reached unexpectedly
 
- 
readFully
public void readFully(byte[] data) throws java.io.IOException, java.io.EOFExceptionInvokes the delegate'sread(byte[] data, int, int)method.- Specified by:
 readFullyin interfacejava.io.DataInput- Parameters:
 data- the buffer to read the bytes into- Throws:
 java.io.EOFException- if an end of file is reached unexpectedlyjava.io.IOException- if an I/O error occurs.
 
- 
readFully
public void readFully(byte[] data, int offset, int length) throws java.io.IOException, java.io.EOFExceptionInvokes the delegate'sread(byte[] data, int, int)method.- Specified by:
 readFullyin interfacejava.io.DataInput- Parameters:
 data- the buffer to read the bytes intooffset- The start offsetlength- The number of bytes to read- Throws:
 java.io.EOFException- if an end of file is reached unexpectedlyjava.io.IOException- if an I/O error occurs.
 
- 
readInt
public int readInt() throws java.io.IOException, java.io.EOFExceptionReads a 4 byte, two's complement little-endian integer.- Specified by:
 readIntin interfacejava.io.DataInput- Returns:
 - the read int
 - Throws:
 java.io.EOFException- if an end of file is reached unexpectedlyjava.io.IOException- if an I/O error occurs.
 
- 
readLine
public java.lang.String readLine() throws java.io.IOException, java.io.EOFExceptionNot currently supported - throwsUnsupportedOperationException.- Specified by:
 readLinein interfacejava.io.DataInput- Returns:
 - the line read
 - Throws:
 java.io.EOFException- if an end of file is reached unexpectedlyjava.io.IOException- if an I/O error occursjava.lang.UnsupportedOperationException- always
 
- 
readLong
public long readLong() throws java.io.IOException, java.io.EOFExceptionReads an 8 byte, two's complement little-endian integer.- Specified by:
 readLongin interfacejava.io.DataInput- Returns:
 - the read long
 - Throws:
 java.io.EOFException- if an end of file is reached unexpectedlyjava.io.IOException- if an I/O error occurs.
 
- 
readShort
public short readShort() throws java.io.IOException, java.io.EOFExceptionReads a 2 byte, two's complement, little-endian integer.- Specified by:
 readShortin interfacejava.io.DataInput- Returns:
 - the read short
 - Throws:
 java.io.EOFException- if an end of file is reached unexpectedlyjava.io.IOException- if an I/O error occurs.
 
- 
readUnsignedByte
public int readUnsignedByte() throws java.io.IOException, java.io.EOFExceptionInvokes the delegate'sread()method.- Specified by:
 readUnsignedBytein interfacejava.io.DataInput- Returns:
 - the byte read or -1 if the end of stream
 - Throws:
 java.io.EOFException- if an end of file is reached unexpectedlyjava.io.IOException- if an I/O error occurs.
 
- 
readUnsignedShort
public int readUnsignedShort() throws java.io.IOException, java.io.EOFExceptionReads a 2 byte, unsigned, little-endian integer.- Specified by:
 readUnsignedShortin interfacejava.io.DataInput- Returns:
 - the read short
 - Throws:
 java.io.EOFException- if an end of file is reached unexpectedlyjava.io.IOException- if an I/O error occurs.
 
- 
readUTF
public java.lang.String readUTF() throws java.io.IOException, java.io.EOFExceptionNot currently supported - throwsUnsupportedOperationException.- Specified by:
 readUTFin interfacejava.io.DataInput- Returns:
 - never
 - Throws:
 java.io.EOFException- if an end of file is reached unexpectedlyjava.io.IOException- if an I/O error occursjava.lang.UnsupportedOperationException- always
 
- 
skipBytes
public int skipBytes(int count) throws java.io.IOExceptionInvokes the delegate'sskip(int)method.- Specified by:
 skipBytesin interfacejava.io.DataInput- Parameters:
 count- the number of bytes to skip- Returns:
 - the number of bytes skipped or -1 if the end of stream
 - Throws:
 java.io.IOException- if an I/O error occurs
 
 - 
 
 -