public class LittleEndianInputStream
extends java.io.FilterInputStream
implements java.io.DataInput
DataInputStream but reads values using
little-endian encoding. Apart from that, it provides a method
that reads an UTF-8 encoded string without reading the number of
bytes from the input stream.| Modifier and Type | Field and Description |
|---|---|
protected java.nio.ByteBuffer |
_buf
Wraps around
_rawBuf |
protected java.nio.CharBuffer |
_lineBuffer
A buffer that will lazily be initialized by
readLine() |
protected byte[] |
_rawBuf
A small buffer to speed up reading slightly
|
protected static StaticBuffers.Key |
UTF8_BUFFER
A unique key for a buffer used in
readUTF(DataInput, int) |
| Constructor and Description |
|---|
LittleEndianInputStream(java.io.InputStream in) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
java.lang.String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
java.lang.String |
readUTF()
Forwards to
DataInputStream.readUTF(DataInput) which expects
a short value at the beginning of the UTF-8 string that specifies
the number of bytes to read. |
java.lang.String |
readUTF(java.io.DataInput input,
int len)
Reads a modified UTF-8 string from a DataInput object
|
java.lang.String |
readUTF(int len)
Reads a modified UTF-8 string
|
int |
skipBytes(int n) |
protected static final StaticBuffers.Key UTF8_BUFFER
readUTF(DataInput, int)protected byte[] _rawBuf
protected java.nio.ByteBuffer _buf
_rawBufprotected java.nio.CharBuffer _lineBuffer
readLine()public LittleEndianInputStream(java.io.InputStream in)
FilterInputStream.FilterInputStream(InputStream)public void readFully(byte[] b)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic int skipBytes(int n)
throws java.io.IOException
skipBytes in interface java.io.DataInputjava.io.IOExceptionpublic boolean readBoolean()
throws java.io.IOException
readBoolean in interface java.io.DataInputjava.io.IOExceptionpublic byte readByte()
throws java.io.IOException
readByte in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedByte()
throws java.io.IOException
readUnsignedByte in interface java.io.DataInputjava.io.IOExceptionpublic short readShort()
throws java.io.IOException
readShort in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedShort()
throws java.io.IOException
readUnsignedShort in interface java.io.DataInputjava.io.IOExceptionpublic char readChar()
throws java.io.IOException
readChar in interface java.io.DataInputjava.io.IOExceptionpublic int readInt()
throws java.io.IOException
readInt in interface java.io.DataInputjava.io.IOExceptionpublic long readLong()
throws java.io.IOException
readLong in interface java.io.DataInputjava.io.IOExceptionpublic float readFloat()
throws java.io.IOException
readFloat in interface java.io.DataInputjava.io.IOExceptionpublic double readDouble()
throws java.io.IOException
readDouble in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readLine()
throws java.io.IOException
readLine in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readUTF()
throws java.io.IOException
Forwards to DataInputStream.readUTF(DataInput) which expects
a short value at the beginning of the UTF-8 string that specifies
the number of bytes to read.
If the output stream does no include such a short value, use
readUTF(int) to explicitly specify the number of bytes.
readUTF in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readUTF(int len)
throws java.io.IOException
len - the number of bytes to read (please do not mix that up
with the number of characters!). If this is -1 then the method
will read bytes until the first one is zero (0x00). The zero
byte will not be included in the result string.java.io.IOException - if an I/O error occursjava.nio.charset.CharacterCodingException - if an invalid UTF-8 character
has been readpublic java.lang.String readUTF(java.io.DataInput input,
int len)
throws java.io.IOException
input - the DataInput object to read fromlen - the number of bytes to read (please do not mix that up
with the number of characters!). If this is -1 then the method
will read bytes until the first one is zero (0x00). The zero
byte will not be included in the result string.java.io.IOException - if an I/O error occursjava.nio.charset.CharacterCodingException - if an invalid UTF-8 character
has been read