Class Expander
- java.lang.Object
-
- org.apache.commons.compress.archivers.examples.Expander
-
public class Expander extends java.lang.ObjectProvides a high level API for expanding archives.- Since:
- 1.17
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interfaceExpander.ArchiveEntrySupplierprivate static interfaceExpander.EntryWriter
-
Constructor Summary
Constructors Constructor Description Expander()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidexpand(java.io.File archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(java.io.InputStream archive, java.io.File targetDirectory)Deprecated.this method leaks resourcesvoidexpand(java.io.InputStream archive, java.io.File targetDirectory, CloseableConsumer closeableConsumer)ExpandsarchiveintotargetDirectory.voidexpand(java.lang.String format, java.io.File archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(java.lang.String format, java.io.InputStream archive, java.io.File targetDirectory)Deprecated.this method leaks resourcesvoidexpand(java.lang.String format, java.io.InputStream archive, java.io.File targetDirectory, CloseableConsumer closeableConsumer)ExpandsarchiveintotargetDirectory.voidexpand(java.lang.String format, java.nio.channels.SeekableByteChannel archive, java.io.File targetDirectory)Deprecated.this method leaks resourcesvoidexpand(java.lang.String format, java.nio.channels.SeekableByteChannel archive, java.io.File targetDirectory, CloseableConsumer closeableConsumer)ExpandsarchiveintotargetDirectory.voidexpand(ArchiveInputStream archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.private voidexpand(Expander.ArchiveEntrySupplier supplier, Expander.EntryWriter writer, java.io.File targetDirectory)voidexpand(SevenZFile archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(TarFile archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(ZipFile archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.private booleanprefersSeekableByteChannel(java.lang.String format)
-
-
-
Method Detail
-
expand
public void expand(java.io.File archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveExceptionExpandsarchiveintotargetDirectory.Tries to auto-detect the archive's format.
- Parameters:
archive- the file to expandtargetDirectory- the directory to write to- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons
-
expand
public void expand(java.lang.String format, java.io.File archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveExceptionExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the directory to write toformat- the archive format. This uses the same format as accepted byArchiveStreamFactory.- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons
-
expand
@Deprecated public void expand(java.io.InputStream archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveExceptionDeprecated.this method leaks resourcesExpandsarchiveintotargetDirectory.Tries to auto-detect the archive's format.
This method creates a wrapper around the archive stream which is never closed and thus leaks resources, please use
expand(InputStream,File,CloseableConsumer)instead.- Parameters:
archive- the file to expandtargetDirectory- the directory to write to- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons
-
expand
public void expand(java.io.InputStream archive, java.io.File targetDirectory, CloseableConsumer closeableConsumer) throws java.io.IOException, ArchiveExceptionExpandsarchiveintotargetDirectory.Tries to auto-detect the archive's format.
This method creates a wrapper around the archive stream and the caller of this method is responsible for closing it - probably at the same time as closing the stream itself. The caller is informed about the wrapper object via the
closeableConsumercallback as soon as it is no longer needed by this class.- Parameters:
archive- the file to expandtargetDirectory- the directory to write tocloseableConsumer- is informed about the stream wrapped around the passed in stream- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons- Since:
- 1.19
-
expand
@Deprecated public void expand(java.lang.String format, java.io.InputStream archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveExceptionDeprecated.this method leaks resourcesExpandsarchiveintotargetDirectory.This method creates a wrapper around the archive stream which is never closed and thus leaks resources, please use
expand(String,InputStream,File,CloseableConsumer)instead.- Parameters:
archive- the file to expandtargetDirectory- the directory to write toformat- the archive format. This uses the same format as accepted byArchiveStreamFactory.- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons
-
expand
public void expand(java.lang.String format, java.io.InputStream archive, java.io.File targetDirectory, CloseableConsumer closeableConsumer) throws java.io.IOException, ArchiveExceptionExpandsarchiveintotargetDirectory.This method creates a wrapper around the archive stream and the caller of this method is responsible for closing it - probably at the same time as closing the stream itself. The caller is informed about the wrapper object via the
closeableConsumercallback as soon as it is no longer needed by this class.- Parameters:
archive- the file to expandtargetDirectory- the directory to write toformat- the archive format. This uses the same format as accepted byArchiveStreamFactory.closeableConsumer- is informed about the stream wrapped around the passed in stream- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons- Since:
- 1.19
-
expand
@Deprecated public void expand(java.lang.String format, java.nio.channels.SeekableByteChannel archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveExceptionDeprecated.this method leaks resourcesExpandsarchiveintotargetDirectory.This method creates a wrapper around the archive channel which is never closed and thus leaks resources, please use
expand(String,SeekableByteChannel,File,CloseableConsumer)instead.- Parameters:
archive- the file to expandtargetDirectory- the directory to write toformat- the archive format. This uses the same format as accepted byArchiveStreamFactory.- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons
-
expand
public void expand(java.lang.String format, java.nio.channels.SeekableByteChannel archive, java.io.File targetDirectory, CloseableConsumer closeableConsumer) throws java.io.IOException, ArchiveExceptionExpandsarchiveintotargetDirectory.This method creates a wrapper around the archive channel and the caller of this method is responsible for closing it - probably at the same time as closing the channel itself. The caller is informed about the wrapper object via the
closeableConsumercallback as soon as it is no longer needed by this class.- Parameters:
archive- the file to expandtargetDirectory- the directory to write toformat- the archive format. This uses the same format as accepted byArchiveStreamFactory.closeableConsumer- is informed about the stream wrapped around the passed in channel- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons- Since:
- 1.19
-
expand
public void expand(ArchiveInputStream archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the directory to write to- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons
-
expand
public void expand(TarFile archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the directory to write to- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons- Since:
- 1.21
-
expand
public void expand(ZipFile archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the directory to write to- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons
-
expand
public void expand(SevenZFile archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the directory to write to- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons
-
prefersSeekableByteChannel
private boolean prefersSeekableByteChannel(java.lang.String format)
-
expand
private void expand(Expander.ArchiveEntrySupplier supplier, Expander.EntryWriter writer, java.io.File targetDirectory) throws java.io.IOException
- Throws:
java.io.IOException
-
-