Class Expander
- java.lang.Object
-
- org.apache.commons.compress.archivers.examples.Expander
-
public class Expander extends java.lang.Object
Provides a high level API for expanding archives.- Since:
- 1.17
-
-
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.io.InputStream archive, java.nio.file.Path 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(java.lang.String format, java.nio.channels.SeekableByteChannel archive, java.nio.file.Path targetDirectory, CloseableConsumer closeableConsumer)ExpandsarchiveintotargetDirectory.voidexpand(java.lang.String format, java.nio.file.Path archive, java.nio.file.Path targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(java.nio.file.Path archive, java.nio.file.Path targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(ArchiveInputStream<?> archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(ArchiveInputStream<?> archive, java.nio.file.Path targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(SevenZFile archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(SevenZFile archive, java.nio.file.Path targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(TarFile archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(TarFile archive, java.nio.file.Path targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(ZipFile archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(ZipFile archive, java.nio.file.Path targetDirectory)ExpandsarchiveintotargetDirectory.
-
-
-
Constructor Detail
-
Expander
public Expander()
-
-
Method Detail
-
expand
public void expand(ArchiveInputStream<?> archive, java.io.File targetDirectory) throws java.io.IOException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directory, may be null to simulate output to dev/null on Linux and NUL on Windows.- Throws:
java.io.IOException- if an I/O error occurs
-
expand
public void expand(ArchiveInputStream<?> archive, java.nio.file.Path targetDirectory) throws java.io.IOException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directory, may be null to simulate output to dev/null on Linux and NUL on Windows.- Throws:
java.io.IOException- if an I/O error occurs- Since:
- 1.22
-
expand
public void expand(java.io.File archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.Tries to auto-detect the archive's format.
- Parameters:
archive- the file to expandtargetDirectory- the target directory- 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, ArchiveException
Deprecated.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 target directory- 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, ArchiveException
ExpandsarchiveintotargetDirectory.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 target directorycloseableConsumer- 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
public void expand(java.nio.file.Path archive, java.nio.file.Path targetDirectory) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.Tries to auto-detect the archive's format.
- Parameters:
archive- the file to expandtargetDirectory- the target directory- Throws:
java.io.IOException- if an I/O error occursArchiveException- if the archive cannot be read for other reasons- Since:
- 1.22
-
expand
public void expand(SevenZFile archive, java.io.File targetDirectory) throws java.io.IOException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directory, may be null to simulate output to dev/null on Linux and NUL on Windows.- Throws:
java.io.IOException- if an I/O error occurs
-
expand
public void expand(SevenZFile archive, java.nio.file.Path targetDirectory) throws java.io.IOException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directory, may be null to simulate output to dev/null on Linux and NUL on Windows.- Throws:
java.io.IOException- if an I/O error occurs- Since:
- 1.22
-
expand
public void expand(java.lang.String format, java.io.File archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directoryformat- 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.lang.String format, java.io.InputStream archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveException
Deprecated.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 target directoryformat- 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, ArchiveException
ExpandsarchiveintotargetDirectory.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 target directoryformat- 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
public void expand(java.lang.String format, java.io.InputStream archive, java.nio.file.Path targetDirectory, CloseableConsumer closeableConsumer) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.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 target directoryformat- 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.22
-
expand
public void expand(java.lang.String format, java.nio.file.Path archive, java.nio.file.Path targetDirectory) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directoryformat- 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- Since:
- 1.22
-
expand
@Deprecated public void expand(java.lang.String format, java.nio.channels.SeekableByteChannel archive, java.io.File targetDirectory) throws java.io.IOException, ArchiveException
Deprecated.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 target directoryformat- 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, ArchiveException
ExpandsarchiveintotargetDirectory.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 target directoryformat- 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(java.lang.String format, java.nio.channels.SeekableByteChannel archive, java.nio.file.Path targetDirectory, CloseableConsumer closeableConsumer) throws java.io.IOException, ArchiveException
ExpandsarchiveintotargetDirectory.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 target directoryformat- 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.22
-
expand
public void expand(TarFile archive, java.io.File targetDirectory) throws java.io.IOException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directory, may be null to simulate output to dev/null on Linux and NUL on Windows.- Throws:
java.io.IOException- if an I/O error occurs- Since:
- 1.21
-
expand
public void expand(TarFile archive, java.nio.file.Path targetDirectory) throws java.io.IOException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directory, may be null to simulate output to dev/null on Linux and NUL on Windows.- Throws:
java.io.IOException- if an I/O error occurs- Since:
- 1.22
-
expand
public void expand(ZipFile archive, java.io.File targetDirectory) throws java.io.IOException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directory, may be null to simulate output to dev/null on Linux and NUL on Windows.- Throws:
java.io.IOException- if an I/O error occurs
-
expand
public void expand(ZipFile archive, java.nio.file.Path targetDirectory) throws java.io.IOException
ExpandsarchiveintotargetDirectory.- Parameters:
archive- the file to expandtargetDirectory- the target directory, may be null to simulate output to dev/null on Linux and NUL on Windows.- Throws:
java.io.IOException- if an I/O error occurs- Since:
- 1.22
-
-