neustore.base
Class ByteArray

java.lang.Object
  extended by neustore.base.ByteArray

public class ByteArray
extends java.lang.Object

A class that provides basic read/write operators on a byte array.

Author:
Donghui Zhang <donghui@ccs.neu.edu>

Field Summary
static boolean READ
           
static boolean WRITE
           
 
Constructor Summary
ByteArray(byte[] _buf, boolean isRead)
          Constructor.
 
Method Summary
 void read(byte[] b)
          Reads from the byte array to fill a passed buffer.
 int readInt()
          Reads an integer.
 void write(byte[] b)
          Writes the passed buffer to the byte array.
 void writeInt(int value)
          Writes an integer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ

public static final boolean READ
See Also:
Constant Field Values

WRITE

public static final boolean WRITE
See Also:
Constant Field Values
Constructor Detail

ByteArray

public ByteArray(byte[] _buf,
                 boolean isRead)
Constructor.

Parameters:
_buf - the associated byte array
isRead - whether to read or write
Method Detail

readInt

public int readInt()
            throws java.io.IOException
Reads an integer.

Returns:
the integer
Throws:
java.io.IOException

read

public void read(byte[] b)
          throws java.io.IOException
Reads from the byte array to fill a passed buffer. Note: the number of bytes read is typically equal to b.length.

Parameters:
b - buffer to read to.
Throws:
java.io.IOException

writeInt

public void writeInt(int value)
              throws java.io.IOException
Writes an integer.

Parameters:
value - the integer to write
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Writes the passed buffer to the byte array.

Parameters:
b - the passed buffer
Throws:
java.io.IOException