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.

Variable Index

 o buf
The buffer where data is stored.
 o count
The number of bytes in the buffer.
 o instream
The real stream from which the byte array will be filled with data

Constructor Index

 o ByteUnPackInputStream(InputStream)
Creates a new ByteUnPackInputStream.

Method Index

 o fill()
Fills the byte buffer by reading data from the stream.
 o fill(int)
Fills the byte buffer by reading data from the stream.
 o readBoolean()
Read a boolean.
 o readByte()
Reads an 8 bit byte.
 o readChar()
Reads a 16 bit char.
 o readChars(String)
Reads a String
 o readDouble()
Reads a 64 bit double.
 o readFloat()
Reads a 32 bit float.
 o readInt()
Reads a 32 bit int.
 o readLong()
Reads a 64 bit long.
 o readShort()
Reads a 16 bit short.
 o size()
Returns the current size of the unread local buffer read from the stream when fill'd

Variables

 o buf
  protected byte buf[]
The buffer where data is stored.
 o count
  protected int count
The number of bytes in the buffer.
 o instream
  protected InputStream instream
The real stream from which the byte array will be filled with data

Constructors

 o ByteUnPackInputStream
  public ByteUnPackInputStream(InputStream in)
Creates a new ByteUnPackInputStream.
Parameters:
in - the output stream

Methods

 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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