Class wb.ByteUnPackInputStream
All Packages Class Hierarchy This Package Previous Next Index
Class wb.ByteUnPackInputStream
java.lang.Object
|
+----wb.ByteUnPackInputStream
- public class ByteUnPackInputStream
- extends Object
This class lets you read primitive Java data types
from a local byte array after the data is read in one single block
in a portable way. Primitive data types are well
understood types with associated operations. For example, an
Integer is considered to be a good primitive data type.
The byte data can be generated using a BytePackOutputStream.
-
buf
- The buffer where data is stored.
-
count
- The number of bytes in the buffer.
-
instream
- The real stream from which the byte array will be filled with data
-
ByteUnPackInputStream(InputStream)
- Creates a new ByteUnPackInputStream.
-
fill()
- Fills the byte buffer by reading data from the stream.
-
fill(int)
- Fills the byte buffer by reading data from the stream.
-
readBoolean()
- Read a boolean.
-
readByte()
- Reads an 8 bit byte.
-
readChar()
- Reads a 16 bit char.
-
readChars(String)
- Reads a String
-
readDouble()
- Reads a 64 bit double.
-
readFloat()
- Reads a 32 bit float.
-
readInt()
- Reads a 32 bit int.
-
readLong()
- Reads a 64 bit long.
-
readShort()
- Reads a 16 bit short.
-
size()
- Returns the current size of the unread local buffer read from the stream
when fill'd
buf
protected byte buf[]
- The buffer where data is stored.
count
protected int count
- The number of bytes in the buffer.
instream
protected InputStream instream
- The real stream from which the byte array will be filled with data
ByteUnPackInputStream
public ByteUnPackInputStream(InputStream in)
- Creates a new ByteUnPackInputStream.
- Parameters:
- in - the output stream
fill
public synchronized int fill() throws IOException
- Fills the byte buffer by reading data from the stream.
- Returns:
- the actual number of bytes read, -1 is returned when the end of
stream is reached
- Throws: IOException
- If an I/O error has occurred
fill
public synchronized int fill(int num) throws IOException
- Fills the byte buffer by reading data from the stream.
- Parameters:
- num - the number of bytes to be read
- Returns:
- the actual number of bytes read, -1 is returned when the end of
stream is reached
- Throws: IOException
- If an I/O error has occurred
- Throws: EOFException
- If EOF is reached before all "num" bytes are read
readBoolean
public synchronized boolean readBoolean() throws IOException
- Read a boolean.
- Returns:
- s the boolean read from the localbuffer
- Throws: IOException
- If there is insufficient data in the localbuffer
readByte
public synchronized byte readByte() throws IOException
- Reads an 8 bit byte.
- Returns:
- s the byte value read
- Throws: IOException
- If there is insufficient data in the localbuffer
readShort
public synchronized short readShort() throws IOException
- Reads a 16 bit short.
- Returns:
- s the 16 bit short read
- Throws: IOException
- If there is insufficient data in the localbuffer
readChar
public synchronized char readChar() throws IOException
- Reads a 16 bit char.
- Returns:
- s the char read
- Throws: IOException
- If there is insufficient data in the localbuffer
readInt
public synchronized int readInt() throws IOException
- Reads a 32 bit int.
- Returns:
- s the 32 bit int read
- Throws: IOException
- If there is insufficient data in the localbuffer
readLong
public synchronized long readLong() throws IOException
- Reads a 64 bit long.
- Returns:
- s the 64 bit long read
- Throws: IOException
- If there is insufficient data in the localbuffer
readFloat
public synchronized float readFloat() throws IOException
- Reads a 32 bit float.
- Returns:
- s the 32 bit float read
- Throws: IOException
- If there is insufficient data in the localbuffer
readDouble
public synchronized double readDouble() throws IOException
- Reads a 64 bit double.
- Returns:
- s the 64 bit double read
- Throws: IOException
- If there is insufficient data in the localbuffer
readChars
public synchronized String readChars(String s) throws IOException
- Reads a String
- Returns:
- s a read String that has been terminated by a \n, \r, \r\n or EOF
if unterminated it returns all the available.
- Throws: IOException
- If there is insufficient data in the localbuffer
size
public int size()
- Returns the current size of the unread local buffer read from the stream
when fill'd
- Returns:
- s the size
All Packages Class Hierarchy This Package Previous Next Index