Package com.github.junrar
Class Archive
java.lang.Object
com.github.junrar.Archive
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<FileHeader>
The Main Rar Class; represents a rar Archive
-
Constructor Summary
ConstructorsConstructorDescriptionArchive(VolumeManager volumeManager, UnrarCallback unrarCallback, String password) Archive(File firstVolume, UnrarCallback unrarCallback) Archive(File firstVolume, UnrarCallback unrarCallback, String password) Archive(InputStream rarAsStream) Archive(InputStream rarAsStream, UnrarCallback unrarCallback) Archive(InputStream rarAsStream, UnrarCallback unrarCallback, String password) Archive(InputStream rarAsStream, String password) -
Method Summary
Modifier and TypeMethodDescriptionvoidbytesReadRead(int count) voidclose()Close the underlying compressed file.voidextractFile(FileHeader hd, OutputStream os) Extract the file specified by the given header and write it to the supplied output streamGets all of the headers in the archive.Returns anInputStreamthat will allow to read the file and stream it.booleanbooleanbooleaniterator()voidsetPassword(String password) voidvoidsetVolumeManager(VolumeManager volumeManager) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Archive
public Archive(VolumeManager volumeManager, UnrarCallback unrarCallback, String password) throws RarException, IOException - Throws:
RarExceptionIOException
-
Archive
- Throws:
RarExceptionIOException
-
Archive
- Throws:
RarExceptionIOException
-
Archive
- Throws:
RarExceptionIOException
-
Archive
public Archive(File firstVolume, UnrarCallback unrarCallback, String password) throws RarException, IOException - Throws:
RarExceptionIOException
-
Archive
- Throws:
RarExceptionIOException
-
Archive
public Archive(InputStream rarAsStream, UnrarCallback unrarCallback) throws RarException, IOException - Throws:
RarExceptionIOException
-
Archive
- Throws:
IOExceptionRarException
-
Archive
public Archive(InputStream rarAsStream, UnrarCallback unrarCallback, String password) throws IOException, RarException - Throws:
IOExceptionRarException
-
-
Method Details
-
bytesReadRead
public void bytesReadRead(int count) -
getChannel
-
getHeaders
Gets all of the headers in the archive.- Returns:
- returns the headers.
-
getFileHeaders
- Returns:
- returns all file headers of the archive
-
nextFileHeader
-
getUnrarCallback
-
isEncrypted
- Returns:
- whether the archive is encrypted
- Throws:
RarException- when the main header is not present
-
isPasswordProtected
- Returns:
- whether the archive content is password protected
- Throws:
RarException- when the main header is not present
-
extractFile
Extract the file specified by the given header and write it to the supplied output stream- Parameters:
hd- the header to be extractedos- the outputstream- Throws:
RarException- .
-
getInputStream
Returns anInputStreamthat will allow to read the file and stream it.
Please note that this method will create a pair of Pipe streams and either:
- delegate the work to a
ThreadPoolExecutor, viaArchive.ExtractorExecutorHolder; or - delegate the work to a newly created thread on each call
You can choose which strategy to use by setting the
junrar.extractor.use-executorsystem property.
Defaults to using theThreadPoolExecutor.- Parameters:
hd- the header to be extracted- Returns:
- an
InputStreamfrom which you can read the uncompressed bytes - Throws:
IOException- if any I/O error occur- See Also:
-
Archive.ExtractorExecutorHolder
- delegate the work to a
-
getMainHeader
- Returns:
- returns the main header of this archive
-
isOldFormat
public boolean isOldFormat()- Returns:
- whether the archive is old format
-
close
Close the underlying compressed file.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getVolumeManager
- Returns:
- the volumeManager
-
setVolumeManager
- Parameters:
volumeManager- the volumeManager to set
-
getVolume
- Returns:
- the volume
-
getPassword
-
setPassword
-
setVolume
- Parameters:
volume- the volume to set- Throws:
IOException- .RarException- .
-
iterator
- Specified by:
iteratorin interfaceIterable<FileHeader>
-