Package net.sf.sevenzipjbinding.impl
Class RandomAccessFileOutStream
java.lang.Object
net.sf.sevenzipjbinding.impl.RandomAccessFileOutStream
- All Implemented Interfaces:
Closeable,AutoCloseable,IOutStream,ISeekableStream,ISequentialOutStream
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
ConstructorsConstructorDescriptionRandomAccessFileOutStream(RandomAccessFile randomAccessFile) Constructs an instance from the given random access file. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes random access file.longseek(long offset, int seekOrigin) Move current location pointer to the new offset depending onseekOrigin.
Note: depending on the archive format and the data size this method may be called from different threads.voidsetSize(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.intwrite(byte[] data) Writedatabyte array to the stream.
-
Constructor Details
-
RandomAccessFileOutStream
Constructs an instance from the given random access file.- Parameters:
randomAccessFile- random access file to use
-
-
Method Details
-
seek
Move current location pointer to the new offset depending onseekOrigin.
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:
seekin interfaceISeekableStream- Parameters:
offset- absolute or relative offset in the stream to move toseekOrigin- one of three possible seek origins:
ISeekableStream.SEEK_SET-offsetis an absolute offset to move to,ISeekableStream.SEEK_CUR-offsetis a relative offset from the current position in the stream,ISeekableStream.SEEK_END-offsetis an offset from the end of the stream
- 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 asIInArchive.extract()orSevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. SeeSevenZipExceptionandSevenZipException.printStackTraceExtended()for details.
-
setSize
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:
setSizein interfaceIOutStream- 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 asIInArchive.extract()orSevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. SeeSevenZipExceptionandSevenZipException.printStackTraceExtended()for details.
-
write
Writedatabyte array to the stream. Ifdata.length > 0this function must write at least 1 byte. This function is allowed to write fewer thandata.lengthbytes. You must call thewrite()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:
writein interfaceISequentialOutStream- 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 asIInArchive.extract()orSevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. SeeSevenZipExceptionandSevenZipException.printStackTraceExtended()for details.
-
close
Closes random access file. After this call no more methods should be called.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- seeRandomAccessFile.close()
-