Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
gnu.CORBA.CDR.LittleEndianInputStream
Field Summary |
Fields inherited from class java.io.FilterInputStream | |
in |
Constructor Summary | |
|
Method Summary | |
protected boolean |
|
protected byte |
|
protected char |
|
protected int |
|
protected long |
|
protected short |
|
protected int |
|
protected int |
|
int |
|
int |
|
boolean |
|
byte |
|
char |
|
double |
|
float |
|
void |
|
void |
|
int |
|
String |
|
long |
|
short |
|
String |
|
int |
|
int |
|
int |
|
Methods inherited from class java.io.FilterInputStream | |
available , close , mark , markSupported , read , read , read , reset , skip |
Methods inherited from class java.io.InputStream | |
available , close , mark , markSupported , read , read , read , reset , skip |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public LittleEndianInputStream(InputStream in)
This constructor initializes a newDataInputStream
to read from the specified subordinate stream.
- Parameters:
in
- The subordinateInputStream
to read from
public int read(byte[] b) throws IOException
This method reads bytes from the underlying stream into the specified byte array buffer. It will attempt to fill the buffer completely, but may return a short count if there is insufficient data remaining to be read to fill the buffer.
- Specified by:
- read in interface AbstractDataInput
- Overrides:
- read in interface FilterInputStream
- Parameters:
b
- The buffer into which bytes will be read.
- Returns:
- The actual number of bytes read, or -1 if end of stream reached before reading any bytes.
- Throws:
IOException
- If an error occurs.
public int read(byte[] b, int off, int len) throws IOException
This method reads bytes from the underlying stream into the specified byte array buffer. It will attempt to readlen
bytes and will start storing them at positionoff
into the buffer. This method can return a short count if there is insufficient data remaining to be read to complete the desired read length.
- Specified by:
- read in interface AbstractDataInput
- Overrides:
- read in interface FilterInputStream
- Parameters:
b
- The buffer into which bytes will be read.off
- The offset into the buffer to start storing bytes.len
- The requested number of bytes to read.
- Returns:
- The actual number of bytes read, or -1 if end of stream reached before reading any bytes.
- Throws:
IOException
- If an error occurs.
public boolean readBoolean() throws IOException
This method reads a Java boolean value from an input stream. It does so by reading a single byte of data. If that byte is zero, then the value returned isfalse
. If the byte is non-zero, then the value returned istrue
.This method can read a
boolean
written by an object implementing thewriteBoolean()
method in theDataOutput
interface.
- Specified by:
- readBoolean in interface AbstractDataInput
- Returns:
- The
boolean
value read
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeBoolean
public byte readByte() throws IOException
This method reads a Java byte value from an input stream. The value is in the range of -128 to 127.This method can read a
byte
written by an object implementing thewriteByte()
method in theDataOutput
interface.
- Specified by:
- readByte in interface AbstractDataInput
- Returns:
- The
byte
value read
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeByte
public char readChar() throws IOException
This method reads a Javachar
value from an input stream. It operates by reading two bytes from the stream and converting them to a single 16-bit Javachar
. The two bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1
andbyte2
represent the first and second byte read from the stream respectively, they will be transformed to achar
in the following manner:
(char)(((byte1 & 0xFF) << 8) | (byte2 & 0xFF)
This method can read a
char
written by an object implementing thewriteChar()
method in theDataOutput
interface.
- Specified by:
- readChar in interface AbstractDataInput
- Returns:
- The
char
value read
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeChar
public double readDouble() throws IOException
This method reads a Java double value from an input stream. It operates by first reading along
value from the stream by calling thereadLong()
method in this interface, then converts thatlong
to adouble
using thelongBitsToDouble
method in the classjava.lang.Double
This method can read a
double
written by an object implementing thewriteDouble()
method in theDataOutput
interface.
- Specified by:
- readDouble in interface AbstractDataInput
- Returns:
- The
double
value read
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeDouble
,Double.longBitsToDouble(long)
public float readFloat() throws IOException
This method reads a Java float value from an input stream. It operates by first reading anint
value from the stream by calling thereadInt()
method in this interface, then converts thatint
to afloat
using theintBitsToFloat
method in the classjava.lang.Float
This method can read a
float
written by an object implementing thewriteFloat()
method in theDataOutput
interface.
- Specified by:
- readFloat in interface AbstractDataInput
- Returns:
- The
float
value read
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeFloat
,Float.intBitsToFloat(int)
public void readFully(byte[] b) throws IOException
This method reads raw bytes into the passed array until the array is full. Note that this method blocks until the data is available and throws an exception if there is not enough data left in the stream to fill the buffer. Note also that zero length buffers are permitted. In this case, the method will return immediately without reading any bytes from the stream.
- Specified by:
- readFully in interface AbstractDataInput
- Parameters:
b
- The buffer into which to read the data
- Throws:
IOException
- If any other error occurs
public void readFully(byte[] buf, int offset, int len) throws IOException
This method reads raw bytes into the passed arraybuf
startingoffset
bytes into the buffer. The number of bytes read will be exactlylen
. Note that this method blocks until the data is available and throws an exception if there is not enough data left in the stream to readlen
bytes. Note also that zero length buffers are permitted. In this case, the method will return immediately without reading any bytes from the stream.
- Parameters:
buf
- The buffer into which to read the dataoffset
- The offset into the buffer to start storing datalen
- The number of bytes to read into the buffer
- Throws:
IOException
- If any other error occurs
public int readInt() throws IOException
This method reads a Javaint
value from an input stream It operates by reading four bytes from the stream and converting them to a single Javaint
. The bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1
throughbyte4
represent the first four bytes read from the stream, they will be transformed to anint
in the following manner:
(int)(((byte1 & 0xFF) << 24) + ((byte2 & 0xFF) << 16) + ((byte3 & 0xFF)<< 8) + (byte4 & 0xFF)))
The value returned is in the range of -2147483648 to 2147483647.
This method can read an
int
written by an object implementing thewriteInt()
method in theDataOutput
interface.
- Specified by:
- readInt in interface AbstractDataInput
- Returns:
- The
int
value read
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeInt
public String readLine() throws IOException
Deprecated.
This method reads the next line of text data from an input stream. It operates by reading bytes and converting those bytes tochar
values by treating the byte read as the low eight bits of thechar
and using 0 as the high eight bits. Because of this, it does not support the full 16-bit Unicode character set.The reading of bytes ends when either the end of file or a line terminator is encountered. The bytes read are then returned as a
String
A line terminator is a byte sequence consisting of either\r
,\n
or\r\n
. These termination charaters are discarded and are not returned as part of the string.This method can read data that was written by an object implementing the
writeLine()
method inDataOutput
.
- Returns:
- The line read as a
String
- Throws:
IOException
- If an error occurs
- See Also:
DataOutput
public long readLong() throws IOException
This method reads a Javalong
value from an input stream It operates by reading eight bytes from the stream and converting them to a single Javalong
. The bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1
throughbyte8
represent the first eight bytes read from the stream, they will be transformed to anlong
in the following manner:
(long)(((byte1 & 0xFF) << 56) + ((byte2 & 0xFF) << 48) + ((byte3 & 0xFF) << 40) + ((byte4 & 0xFF) << 32) + ((byte5 & 0xFF) << 24) + ((byte6 & 0xFF) << 16) + ((byte7 & 0xFF) << 8) + (byte8 & 0xFF)))
The value returned is in the range of -9223372036854775808 to 9223372036854775807.
This method can read an
long
written by an object implementing thewriteLong()
method in theDataOutput
interface.
- Specified by:
- readLong in interface AbstractDataInput
- Returns:
- The
long
value read
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeLong
public short readShort() throws IOException
This method reads a signed 16-bit value into a Java in from the stream. It operates by reading two bytes from the stream and converting them to a single 16-bit Javashort
. The two bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1
andbyte2
represent the first and second byte read from the stream respectively, they will be transformed to ashort
. in the following manner:
(short)(((byte1 & 0xFF) << 8) | (byte2 & 0xFF))
The value returned is in the range of -32768 to 32767.
This method can read a
short
written by an object implementing thewriteShort()
method in theDataOutput
interface.
- Specified by:
- readShort in interface AbstractDataInput
- Returns:
- The
short
value read
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeShort
public int readUnsignedByte() throws IOException
This method reads 8 unsigned bits into a Javaint
value from the stream. The value returned is in the range of 0 to 255.This method can read an unsigned byte written by an object implementing the
writeUnsignedByte()
method in theDataOutput
interface.
- Specified by:
- readUnsignedByte in interface AbstractDataInput
- Returns:
- The unsigned bytes value read as a Java
int
.
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeByte
public int readUnsignedShort() throws IOException
This method reads 16 unsigned bits into a Java int value from the stream. It operates by reading two bytes from the stream and converting them to a single Javaint
The two bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1
andbyte2
represent the first and second byte read from the stream respectively, they will be transformed to anint
in the following manner:
(int)(((byte1 & 0xFF) << 8) + (byte2 & 0xFF))
The value returned is in the range of 0 to 65535.
This method can read an unsigned short written by an object implementing the
writeUnsignedShort()
method in theDataOutput
interface.
- Specified by:
- readUnsignedShort in interface AbstractDataInput
- Returns:
- The unsigned short value read as a Java
int
- Throws:
IOException
- If any other error occurs
- See Also:
DataOutput.writeShort
public int skipBytes(int n) throws IOException
This method attempts to skip and discard the specified number of bytes in the input stream. It may actually skip fewer bytes than requested. This method will not skip any bytes if passed a negative number of bytes to skip.
- Specified by:
- skipBytes in interface AbstractDataInput
- Parameters:
n
- The requested number of bytes to skip.
- Returns:
- The requested number of bytes to skip.
- Throws:
IOException
- If an error occurs.