public class EndianNeutralDataInputStream
extends java.lang.Object
implements java.io.DataInput
Constructor and Description |
---|
EndianNeutralDataInputStream(java.io.InputStream in,
boolean intelByteOrder) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
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. |
double |
readDouble()
Reads an eight byte
double from the underlying
input stream. |
float |
readFloat()
Reads a four byte
float from the underlying
input stream. |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt()
Reads a four byte signed
int from the underlying
input stream. |
java.lang.String |
readLine()
Deprecated.
This method does not properly convert bytes to characters.
Use a Reader instead with a little-endian encoding.
|
long |
readLong()
Reads an eight byte signed
long from the underlying
input stream. |
short |
readShort()
Reads a two byte signed
short from the underlying
input stream. |
int |
readUnsignedByte()
Reads an unsigned
byte from the underlying
input stream with value between 0 and 255 |
long |
readUnsignedInt()
Reads a four byte unsigned
int from the underlying
input stream. |
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 n)
Skip exactly
n bytes of input in the underlying
input stream. |
public EndianNeutralDataInputStream(java.io.InputStream in, boolean intelByteOrder)
public void close() throws java.io.IOException
java.io.IOException
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.DataInput
boolean
value read.java.io.EOFException
- if the end of the underlying input stream
has been reachedjava.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 127readByte
in interface java.io.DataInput
byte
value read.java.io.EOFException
- if the end of the underlying input stream
has been reachedjava.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 255readUnsignedByte
in interface java.io.DataInput
byte
value read.java.io.EOFException
- if the end of the underlying input
stream has been reachedjava.io.IOException
- if the underlying stream throws an IOException.public short readShort() throws java.io.IOException
short
from the underlying
input stream.readShort
in interface java.io.DataInput
short
read.java.io.EOFException
- if the end of the underlying input stream
has been reachedjava.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.DataInput
java.io.EOFException
- if the end of the underlying input stream
has been reachedjava.io.IOException
- if the underlying stream throws an IOException.public char readChar() throws java.io.IOException
char
from the underlying
input stream.readChar
in interface java.io.DataInput
java.io.EOFException
- if the end of the underlying input stream
has been reachedjava.io.IOException
- if the underlying stream throws an IOException.public int readInt() throws java.io.IOException
int
from the underlying
input stream.readInt
in interface java.io.DataInput
int
read.java.io.EOFException
- if the end of the underlying input stream
has been reachedjava.io.IOException
- if the underlying stream throws an IOException.public long readUnsignedInt() throws java.io.IOException
int
from the underlying
input stream.int
read, as a long
.java.io.EOFException
- if the end of the underlying input stream
has been reachedjava.io.IOException
- if the underlying stream throws an IOException.public long readLong() throws java.io.IOException
long
from the underlying
input stream.readLong
in interface java.io.DataInput
long
read.java.io.EOFException
- if the end of the underlying input stream
has been reachedjava.io.IOException
- if the underlying stream throws an IOException.public java.lang.String readUTF() throws java.io.IOException
readUTF
in interface java.io.DataInput
java.io.UTFDataFormatException
- if the string cannot be decodedjava.io.IOException
- if the underlying stream throws an IOException.public final double readDouble() throws java.io.IOException
double
from the underlying
input stream.readDouble
in interface java.io.DataInput
double
read.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
float
from the underlying
input stream.readFloat
in interface java.io.DataInput
float
read.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 n) throws java.io.IOException
n
bytes of input in the underlying
input stream. This method blocks until all the bytes are skipped,
the end of the stream is detected, or an exception is thrown.skipBytes
in interface java.io.DataInput
n
- the number of bytes to skip.java.io.EOFException
- if this input stream reaches the end before
skipping all the bytes.java.io.IOException
- if the underlying stream throws an IOException.public final void readFully(byte[] b) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
DataInput.readFully(byte[])
public final void readFully(byte[] b, int off, int len) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
DataInput.readFully(byte[], int, int)
@Deprecated public final java.lang.String readLine() throws java.io.IOException
readLine
in interface java.io.DataInput
java.io.IOException