com.github.junrar.io
Class ReadOnlyAccessByteArray

java.lang.Object
  extended by com.github.junrar.io.ReadOnlyAccessByteArray
All Implemented Interfaces:
IReadOnlyAccess

public class ReadOnlyAccessByteArray
extends Object
implements IReadOnlyAccess

A File like access to a byte array. (seek and read certain number of bytes)

Version:
$LastChangedRevision$
Author:
$LastChangedBy$

Constructor Summary
ReadOnlyAccessByteArray(byte[] file)
          Initialize with byte[ ]
 
Method Summary
 void close()
          Close this file.
 long getPosition()
           
 int read()
          Read a single byte of data.
 int read(byte[] buffer, int off, int count)
          Read up to count bytes to the specified buffer.
 int readFully(byte[] buffer, int count)
          Read exactly count bytes to the specified buffer.
 void setPosition(long pos)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyAccessByteArray

public ReadOnlyAccessByteArray(byte[] file)
Initialize with byte[ ]

Parameters:
file - the file given as byte array
Method Detail

getPosition

public long getPosition()
                 throws IOException
Specified by:
getPosition in interface IReadOnlyAccess
Returns:
the current position in the file
Throws:
IOException

setPosition

public void setPosition(long pos)
                 throws IOException
Specified by:
setPosition in interface IReadOnlyAccess
Parameters:
pos - the position in the file
Throws:
IOException

read

public int read()
         throws IOException
Read a single byte of data.

Specified by:
read in interface IReadOnlyAccess
Throws:
IOException

read

public int read(byte[] buffer,
                int off,
                int count)
         throws IOException
Read up to count bytes to the specified buffer.

Specified by:
read in interface IReadOnlyAccess
Throws:
IOException

readFully

public int readFully(byte[] buffer,
                     int count)
              throws IOException
Description copied from interface: IReadOnlyAccess
Read exactly count bytes to the specified buffer.

Specified by:
readFully in interface IReadOnlyAccess
Parameters:
buffer - where to store the read data
count - how many bytes to read
Returns:
bytes read || -1 if IO problem
Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: IReadOnlyAccess
Close this file.

Specified by:
close in interface IReadOnlyAccess
Throws:
IOException


Copyright © 2012. All Rights Reserved.