net.sf.sevenzipjbinding.impl
Class RandomAccessFileInStream

java.lang.Object
  extended by net.sf.sevenzipjbinding.impl.RandomAccessFileInStream
All Implemented Interfaces:
IInStream, ISequentialInStream

public class RandomAccessFileInStream
extends java.lang.Object
implements IInStream

Implementation of IInStream using RandomAccessFile.

Version:
4.65-1
Author:
Boris Brodski

Field Summary
 
Fields inherited from interface net.sf.sevenzipjbinding.IInStream
SEEK_CUR, SEEK_END, SEEK_SET
 
Constructor Summary
RandomAccessFileInStream(java.io.RandomAccessFile randomAccessFile)
          Constructs instance of the class from random access file.
 
Method Summary
 void close()
          Closes random access file.
 int read(byte[] data)
          Reads at least 1 and maximum data.length from the in-stream.
 long seek(long offset, int seekOrigin)
          Move current location pointer to the new offset depending on seekOrigin
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomAccessFileInStream

public RandomAccessFileInStream(java.io.RandomAccessFile randomAccessFile)
Constructs instance of the class from random access file.

Parameters:
randomAccessFile - random access file to use
Method Detail

seek

public long seek(long offset,
                 int seekOrigin)
          throws SevenZipException
Move current location pointer to the new offset depending on seekOrigin

Specified by:
seek in interface IInStream
Parameters:
offset - absolute or relative offset in the stream to move to
seekOrigin - on of three possible seek origins:
  • IInStream.SEEK_SET - offset is an absolute offset to move to,
  • IInStream.SEEK_CUR - offset is a relative offset to the current position in stream,
  • IInStream.SEEK_END - offset is an offset from the end of the stream (offset <= 0).
    Returns:
    new absolute position in the stream.
    Throws:
    SevenZipException - in error case. If this method ends with an exception, the current operation will be reported to 7-Zip as failed. There are no guarantee, that there are no further call back methods will be called. The first thrown exception will be saved and thrown late on from the first called 7-Zip-JBinding main method, such as ISevenZipInArchive.extract() or SevenZip.openInArchive().

  • read

    public int read(byte[] data)
             throws SevenZipException
    Reads at least 1 and maximum data.length from the in-stream. If data.length == 0 0 should be returned. If data.length != 0, then return value 0 indicates end-of-stream (EOF). This means no more bytes can be read from the stream.
    This function is allowed to read less than number of remaining bytes in stream and less then data.length. You must call read() function in loop, if you need exact amount of data.

    Specified by:
    read in interface ISequentialInStream
    Parameters:
    data - buffer to get read data
    Returns:
    amount of bytes written in the data array. 0 - represents end of stream.
    Throws:
    SevenZipException - in error case. If this method ends with an exception, the current operation will be reported to 7-Zip as failed. There are no guarantee, that there are no further call back methods will be called. The first thrown exception will be saved and thrown late on from the first called 7-Zip-JBinding main method, such as ISevenZipInArchive.extract() or SevenZip.openInArchive().

    close

    public void close()
               throws java.io.IOException
    Closes random access file. After this call no more methods should be called.

    Throws:
    java.io.IOException