org.apache.commons.io.input

Class SwappedDataInputStream

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)

Version: CVS $Revision: 610010 $ $Date: 2008-01-08 14:50:59 +0000 (Tue, 08 Jan 2008) $

Author: Peter Donald

Constructor Summary
SwappedDataInputStream(InputStream input)
Constructs a SwappedDataInputStream.
Method Summary
booleanreadBoolean()
Return readByte == 0
bytereadByte()
Invokes the delegate's read() method.
charreadChar()
Reads a character delegating to readShort.
doublereadDouble()
Delegates to readSwappedDouble.
floatreadFloat()
Delegates to readSwappedFloat.
voidreadFully(byte[] data)
Invokes the delegate's read(byte[] data, int, int) method.
voidreadFully(byte[] data, int offset, int length)
Invokes the delegate's read(byte[] data, int, int) method.
intreadInt()
Delegates to readSwappedInteger.
StringreadLine()
Not currently supported - throws UnsupportedOperationException.
longreadLong()
Delegates to readSwappedLong.
shortreadShort()
Delegates to readSwappedShort.
intreadUnsignedByte()
Invokes the delegate's read() method.
intreadUnsignedShort()
StringreadUTF()
Not currently supported - throws UnsupportedOperationException.
intskipBytes(int count)
Invokes the delegate's skip(int) method.

Constructor Detail

SwappedDataInputStream

public SwappedDataInputStream(InputStream input)
Constructs a SwappedDataInputStream.

Parameters: input InputStream to read from

Method Detail

readBoolean

public boolean readBoolean()
Return readByte == 0

Returns: the true if the byte read is zero, otherwise false

Throws: IOException if an I/O error occurs EOFException if an end of file is reached unexpectedly

readByte

public byte readByte()
Invokes the delegate's read() method.

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()
Reads a character delegating to readShort.

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()
Delegates to readSwappedDouble.

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()
Delegates to readSwappedFloat.

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)
Invokes the delegate's read(byte[] data, int, int) method.

Parameters: data the buffer to read the bytes into

Throws: EOFException if an end of file is reached unexpectedly IOException if an I/O error occurs

readFully

public void readFully(byte[] data, int offset, int length)
Invokes the delegate's read(byte[] data, int, int) method.

Parameters: data the buffer to read the bytes into offset The start offset length The number of bytes to read

Throws: EOFException if an end of file is reached unexpectedly IOException if an I/O error occurs

readInt

public int readInt()
Delegates to readSwappedInteger.

Returns: the read long

Throws: EOFException if an end of file is reached unexpectedly IOException if an I/O error occurs

readLine

public String readLine()
Not currently supported - throws UnsupportedOperationException.

Returns: the line read

Throws: EOFException if an end of file is reached unexpectedly IOException if an I/O error occurs

readLong

public long readLong()
Delegates to readSwappedLong.

Returns: the read long

Throws: EOFException if an end of file is reached unexpectedly IOException if an I/O error occurs

readShort

public short readShort()
Delegates to readSwappedShort.

Returns: the read long

Throws: EOFException if an end of file is reached unexpectedly IOException if an I/O error occurs

readUnsignedByte

public int readUnsignedByte()
Invokes the delegate's read() method.

Returns: the byte read or -1 if the end of stream

Throws: EOFException if an end of file is reached unexpectedly IOException if an I/O error occurs

readUnsignedShort

public int readUnsignedShort()
Delegates to readSwappedUnsignedShort.

Returns: the read long

Throws: EOFException if an end of file is reached unexpectedly IOException if an I/O error occurs

readUTF

public String readUTF()
Not currently supported - throws UnsupportedOperationException.

Returns: UTF String read

Throws: EOFException if an end of file is reached unexpectedly IOException if an I/O error occurs

skipBytes

public int skipBytes(int count)
Invokes the delegate's skip(int) method.

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 unexpectedly IOException if an I/O error occurs

Copyright (c) 2002-2011 Apache Software Foundation