Class RandomAccessFileOutStream

java.lang.Object
net.sf.sevenzipjbinding.impl.RandomAccessFileOutStream
All Implemented Interfaces:
Closeable, AutoCloseable, IOutStream, ISeekableStream, ISequentialOutStream

public class RandomAccessFileOutStream extends Object implements IOutStream, Closeable
Implementation of IOutStream using RandomAccessFile.
Since:
4.65-1
Author:
Boris Brodski
  • Field Summary

    Fields inherited from interface net.sf.sevenzipjbinding.ISeekableStream

    SEEK_CUR, SEEK_END, SEEK_SET
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an instance from the given random access file.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes random access file.
    long
    seek(long offset, int seekOrigin)
    Move current location pointer to the new offset depending on seekOrigin.

    Note: depending on the archive format and the data size this method may be called from different threads.
    void
    setSize(long newSize)
    Set new size for the out stream.

    Note: depending on the archive format and the data size this method may be called from different threads.
    int
    write(byte[] data)
    Write data byte array to the stream.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandomAccessFileOutStream

      public RandomAccessFileOutStream(RandomAccessFile randomAccessFile)
      Constructs an instance from the given random access file.
      Parameters:
      randomAccessFile - random access file to use
  • Method Details

    • seek

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

      Note: depending on the archive format and the data size this method may be called from different threads. Synchronized implementation may be required.
      Specified by:
      seek in interface ISeekableStream
      Parameters:
      offset - absolute or relative offset in the stream to move to
      seekOrigin - one of three possible seek origins:
      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 is no guarantee that no further callback methods will be called. The first and last thrown exceptions will be saved and thrown later on from the originally called method such as IInArchive.extract() or SevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. See SevenZipException and SevenZipException.printStackTraceExtended() for details.
    • setSize

      public void setSize(long newSize) throws SevenZipException
      Set new size for the out stream.

      Note: depending on the archive format and the data size this method may be called from different threads. Synchronized implementation may be required.
      Specified by:
      setSize in interface IOutStream
      Parameters:
      newSize - new size
      Throws:
      SevenZipException - in error case. If this method ends with an exception, the current operation will be reported to 7-Zip as failed. There is no guarantee that no further callback methods will be called. The first and last thrown exceptions will be saved and thrown later on from the originally called method such as IInArchive.extract() or SevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. See SevenZipException and SevenZipException.printStackTraceExtended() for details.
    • write

      public int write(byte[] data) throws SevenZipException
      Write data byte array to the stream. If data.length > 0 this function must write at least 1 byte. This function is allowed to write fewer than data.length bytes. You must call the write() function in a loop if you need to write an exact amount of data.

      Note: depending on the archive format and the data size this method may be called from different threads. Synchronized implementation may be required.
      Specified by:
      write in interface ISequentialOutStream
      Parameters:
      data - data to write
      Returns:
      count of written bytes
      Throws:
      SevenZipException - in error case. If this method ends with an exception, the current operation will be reported to 7-Zip as failed. There is no guarantee that no further callback methods will be called. The first and last thrown exceptions will be saved and thrown later on from the originally called method such as IInArchive.extract() or SevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. See SevenZipException and SevenZipException.printStackTraceExtended() for details.
    • close

      public void close() throws IOException
      Closes random access file. After this call no more methods should be called.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - see RandomAccessFile.close()