|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
com.twelvemonkeys.io.LittleEndianDataInputStream
public class LittleEndianDataInputStream
A little endian input stream reads two's complement, little endian integers, floating point numbers, and characters and returns them as Java primitive types.
The standardjava.io.DataInputStream class
which this class imitates reads big endian quantities.
Warning:
The DataInput and DataOutput interfaces
specifies big endian byte order in their documentation.
This means that this class is, strictly speaking, not a proper
implementation. However, I don't see a reason for the these interfaces to
specify the byte order of their underlying representations.
LittleEndianRandomAccessFile,
DataInputStream,
DataInput,
DataOutput| Field Summary |
|---|
| Fields inherited from class java.io.FilterInputStream |
|---|
in |
| Constructor Summary | |
|---|---|
LittleEndianDataInputStream(java.io.InputStream pStream)
Creates a new little endian input stream and chains it to the input stream specified by the pStream argument. |
|
| Method Summary | |
|---|---|
boolean |
readBoolean()
Reads a boolean from the underlying input stream by
reading a single byte. |
byte |
readByte()
Reads a signed byte from the underlying input stream
with value between -128 and 127 |
char |
readChar()
Reads a two byte Unicode char from the underlying
input stream in little endian order, low byte first. |
double |
readDouble()
|
float |
readFloat()
|
void |
readFully(byte[] pBytes)
See the general contract of the readFully
method of DataInput. |
void |
readFully(byte[] pBytes,
int pOffset,
int pLength)
See the general contract of the readFully
method of DataInput. |
int |
readInt()
Reads a four byte signed int from the underlying
input stream in little endian order, low byte first. |
java.lang.String |
readLine()
Deprecated. This method does not properly convert bytes to characters. |
long |
readLong()
Reads an eight byte signed int from the underlying
input stream in little endian order, low byte first. |
short |
readShort()
Reads a two byte signed short from the underlying
input stream in little endian order, low byte first. |
int |
readUnsignedByte()
Reads an unsigned byte from the underlying
input stream with value between 0 and 255 |
int |
readUnsignedShort()
Reads a two byte unsigned short from the underlying
input stream in little endian order, low byte first. |
java.lang.String |
readUTF()
Reads a string of no more than 65,535 characters from the underlying input stream using UTF-8 encoding. |
int |
skipBytes(int pLength)
See the general contract of the skipBytes
method of DataInput. |
| Methods inherited from class java.io.FilterInputStream |
|---|
available, close, mark, markSupported, read, read, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LittleEndianDataInputStream(java.io.InputStream pStream)
pStream argument.
pStream - the underlying input stream.FilterInputStream.in| Method Detail |
|---|
public boolean readBoolean()
throws java.io.IOException
boolean from the underlying input stream by
reading a single byte. If the byte is zero, false is returned.
If the byte is positive, true is returned.
readBoolean in interface java.io.DataInputboolean value read.
java.io.EOFException - if the end of the underlying input stream
has been reached
java.io.IOException - if the underlying stream throws an IOException.
public byte readByte()
throws java.io.IOException
byte from the underlying input stream
with value between -128 and 127
readByte in interface java.io.DataInputbyte value read.
java.io.EOFException - if the end of the underlying input stream
has been reached
java.io.IOException - if the underlying stream throws an IOException.
public int readUnsignedByte()
throws java.io.IOException
byte from the underlying
input stream with value between 0 and 255
readUnsignedByte in interface java.io.DataInputbyte value read.
java.io.EOFException - if the end of the underlying input
stream has been reached
java.io.IOException - if the underlying stream throws an IOException.
public short readShort()
throws java.io.IOException
short from the underlying
input stream in little endian order, low byte first.
readShort in interface java.io.DataInputshort read.
java.io.EOFException - if the end of the underlying input stream
has been reached
java.io.IOException - if the underlying stream throws an IOException.
public int readUnsignedShort()
throws java.io.IOException
short from the underlying
input stream in little endian order, low byte first.
readUnsignedShort in interface java.io.DataInputjava.io.EOFException - if the end of the underlying input stream
has been reached
java.io.IOException - if the underlying stream throws an IOException.
public char readChar()
throws java.io.IOException
char from the underlying
input stream in little endian order, low byte first.
readChar in interface java.io.DataInputjava.io.EOFException - if the end of the underlying input stream
has been reached
java.io.IOException - if the underlying stream throws an IOException.
public int readInt()
throws java.io.IOException
int from the underlying
input stream in little endian order, low byte first.
readInt in interface java.io.DataInputint read.
java.io.EOFException - if the end of the underlying input stream
has been reached
java.io.IOException - if the underlying stream throws an IOException.
public long readLong()
throws java.io.IOException
int from the underlying
input stream in little endian order, low byte first.
readLong in interface java.io.DataInputint read.
java.io.EOFException - if the end of the underlying input stream
has been reached
java.io.IOException - if the underlying stream throws an IOException.
public java.lang.String readUTF()
throws java.io.IOException
readUTF in interface java.io.DataInputjava.io.UTFDataFormatException - if the string cannot be decoded
java.io.IOException - if the underlying stream throws an IOException.
public final double readDouble()
throws java.io.IOException
readDouble in interface java.io.DataInputdouble.
java.io.EOFException - if end of stream occurs before eight bytes
have been read.
java.io.IOException - if an I/O error occurs.
public final float readFloat()
throws java.io.IOException
readFloat in interface java.io.DataInputint.
java.io.EOFException - if end of stream occurs before four bytes
have been read.
java.io.IOException - if an I/O error occurs.
public final int skipBytes(int pLength)
throws java.io.IOException
skipBytes
method of DataInput.
Bytes for this operation are read from the contained input stream.
skipBytes in interface java.io.DataInputpLength - the number of bytes to be skipped.
java.io.IOException - if an I/O error occurs.
public final void readFully(byte[] pBytes)
throws java.io.IOException
readFully
method of DataInput.
Bytes
for this operation are read from the contained
input stream.
readFully in interface java.io.DataInputpBytes - the buffer into which the data is read.
java.io.EOFException - if this input stream reaches the end before
reading all the bytes.
java.io.IOException - if an I/O error occurs.FilterInputStream.in
public final void readFully(byte[] pBytes,
int pOffset,
int pLength)
throws java.io.IOException
readFully
method of DataInput.
Bytes
for this operation are read from the contained
input stream.
readFully in interface java.io.DataInputpBytes - the buffer into which the data is read.pOffset - the start offset of the data.pLength - the number of bytes to read.
java.io.EOFException - if this input stream reaches the end before
reading all the bytes.
java.io.IOException - if an I/O error occurs.FilterInputStream.in
public java.lang.String readLine()
throws java.io.IOException
readLine
method of DataInput.
Bytes for this operation are read from the contained input stream.
readLine in interface java.io.DataInputjava.io.IOException - if an I/O error occurs.BufferedReader.readLine(),
DataInputStream.readLine()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||