org.apache.commons.io.input

Class SwappedDataInputStream

Implemented Interfaces:
DataInput

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

boolean
readBoolean()
Return readByte() == 0
byte
readByte()
Invokes the delegate's read() method.
char
readChar()
Reads a character delegating to readShort().
double
readDouble()
Delegates to EndianUtils.readSwappedDouble(InputStream).
float
readFloat()
Delegates to EndianUtils.readSwappedFloat(InputStream).
void
readFully(byte[] data)
Invokes the delegate's read(byte[] data, int, int) method.
void
readFully(byte[] data, int offset, int length)
Invokes the delegate's read(byte[] data, int, int) method.
int
readInt()
Delegates to EndianUtils.readSwappedInteger(InputStream).
String
readLine()
Not currently supported - throws UnsupportedOperationException.
long
readLong()
Delegates to EndianUtils.readSwappedLong(InputStream).
short
readShort()
Delegates to EndianUtils.readSwappedShort(InputStream).
String
readUTF()
Not currently supported - throws UnsupportedOperationException.
int
readUnsignedByte()
Invokes the delegate's read() method.
int
readUnsignedShort()
Delegates to EndianUtils.readSwappedUnsignedShort(InputStream).
int
skipBytes(int count)
Invokes the delegate's skip(int) method.

Methods inherited from class org.apache.commons.io.input.ProxyInputStream

available, close, mark, markSupported, read, read, read, reset, skip

Constructor Details

SwappedDataInputStream

public SwappedDataInputStream(InputStream input)
Constructs a SwappedDataInputStream.
Parameters:
input - InputStream to read from

Method Details

readBoolean

public boolean readBoolean()
            throws IOException,
                   EOFException
Returns:
the true if the byte read is zero, otherwise false

readByte

public byte readByte()
            throws IOException,
                   EOFException
Invokes the delegate's read() method.
Returns:
the byte read or -1 if the end of stream

readChar

public char readChar()
            throws IOException,
                   EOFException
Returns:
the byte read or -1 if the end of stream

readDouble

public double readDouble()
            throws IOException,
                   EOFException
Returns:
the read long

readFloat

public float readFloat()
            throws IOException,
                   EOFException
Returns:
the read long

readFully

public void readFully(byte[] data)
            throws IOException,
                   EOFException
Invokes the delegate's read(byte[] data, int, int) method.
Parameters:
data - the buffer to read the bytes into

readFully

public void readFully(byte[] data,
                      int offset,
                      int length)
            throws IOException,
                   EOFException
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

readInt

public int readInt()
            throws IOException,
                   EOFException
Returns:
the read long

readLine

public String readLine()
            throws IOException,
                   EOFException
Not currently supported - throws UnsupportedOperationException.
Returns:
the line read

readLong

public long readLong()
            throws IOException,
                   EOFException
Returns:
the read long

readShort

public short readShort()
            throws IOException,
                   EOFException
Returns:
the read long

readUTF

public String readUTF()
            throws IOException,
                   EOFException
Not currently supported - throws UnsupportedOperationException.
Returns:
UTF String read

readUnsignedByte

public int readUnsignedByte()
            throws IOException,
                   EOFException
Invokes the delegate's read() method.
Returns:
the byte read or -1 if the end of stream

readUnsignedShort

public int readUnsignedShort()
            throws IOException,
                   EOFException
Returns:
the read long

skipBytes

public int skipBytes(int count)
            throws IOException,
                   EOFException
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

Copyright (c) 2002-2009 Apache Software Foundation