com.fernsroth.easyio
Class RandomAccessByteArray

java.lang.Object
  extended by com.fernsroth.easyio.RandomAccessByteArray
All Implemented Interfaces:
IInputStream, IOutputStream, IRandomAccessSource

public class RandomAccessByteArray
extends java.lang.Object
implements IRandomAccessSource

Author:
Joseph M. Ferner (Near Infinity Corporation)

Constructor Summary
RandomAccessByteArray(byte[] data)
          constructor.
 
Method Summary
 long getFilePointer()
          gets the current location.
 long length()
          gets the length.
 int read()
          read a single byte.
 int read(byte[] buffer)
          
 int read(byte[] buffer, int off, int len)
          
 void seek(long newLocation)
          sets the location.
 void setLength(long length)
          sets the length.
 void write(byte[] buffer)
          writes data.
 void write(byte[] buffer, int start, int length)
          writes data.
 void write(int b)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomAccessByteArray

public RandomAccessByteArray(byte[] data)
constructor.

Parameters:
data - the data.
Method Detail

seek

public void seek(long newLocation)
sets the location.

Specified by:
seek in interface IRandomAccessSource
Parameters:
newLocation - the location.

getFilePointer

public long getFilePointer()
gets the current location.

Specified by:
getFilePointer in interface IRandomAccessSource
Returns:
the current location.

write

public void write(int b)

Specified by:
write in interface IOutputStream
Parameters:
b - the data.

write

public void write(byte[] buffer)
writes data.

Specified by:
write in interface IOutputStream
Parameters:
buffer - the data to write.

write

public void write(byte[] buffer,
                  int start,
                  int length)
writes data.

Specified by:
write in interface IOutputStream
Parameters:
buffer - the data to write.
start - the start.
length - the length.

read

public int read()
read a single byte.

Specified by:
read in interface IInputStream
Returns:
the data read.

read

public int read(byte[] buffer,
                int off,
                int len)

Specified by:
read in interface IInputStream
Parameters:
buffer - the buffer to put the data in.
off - the offset into buffer to start reading into.
len - the length to read.
Returns:
the number of bytes read.

read

public int read(byte[] buffer)

Specified by:
read in interface IInputStream
Parameters:
buffer - the buffer to read data into.
Returns:
the number of bytes read.

setLength

public void setLength(long length)
               throws java.io.IOException
sets the length.

Specified by:
setLength in interface IRandomAccessSource
Parameters:
length - the length.
Throws:
java.io.IOException

length

public long length()
            throws java.io.IOException
gets the length.

Specified by:
length in interface IRandomAccessSource
Returns:
the length.
Throws:
java.io.IOException


Copyright © 2006 null. All Rights Reserved.