- java.lang.Object
-
- kala.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.ArchiveEntryBiConsumer<T extends ArchiveEntry>private static interfaceExpander.ArchiveEntrySupplier<T extends ArchiveEntry>
-
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.private <T extends ArchiveEntry>
voidexpand(Expander.ArchiveEntrySupplier<T> supplier, Expander.ArchiveEntryBiConsumer<T> writer, java.nio.file.Path targetDirectory)voidexpand(SevenZArchiveReader archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(SevenZArchiveReader archive, java.nio.file.Path targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(TarArchiveReader archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(TarArchiveReader archive, java.nio.file.Path targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(ZipArchiveReader archive, java.io.File targetDirectory)ExpandsarchiveintotargetDirectory.voidexpand(ZipArchiveReader archive, java.nio.file.Path targetDirectory)ExpandsarchiveintotargetDirectory.private booleanprefersSeekableByteChannel(java.lang.String format)private java.nio.file.PathtoPath(java.io.File targetDirectory)
-
-
-
Method Detail
-
expand
private <T extends ArchiveEntry> void expand(Expander.ArchiveEntrySupplier<T> supplier, Expander.ArchiveEntryBiConsumer<T> writer, java.nio.file.Path targetDirectory) throws java.io.IOException
- Parameters:
targetDirectory- May be null to simulate output to dev/null on Linux and NUL on Windows.- Throws:
java.io.IOException
-
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, ArchiveExceptionExpandsarchiveintotargetDirectory.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, 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 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, 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 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, ArchiveExceptionExpandsarchiveintotargetDirectory.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(SevenZArchiveReader 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(SevenZArchiveReader 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, ArchiveExceptionExpandsarchiveintotargetDirectory.- 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, 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 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, 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 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, 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 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, ArchiveExceptionExpandsarchiveintotargetDirectory.- 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, 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 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, 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 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, 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 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(TarArchiveReader 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(TarArchiveReader 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(ZipArchiveReader 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(ZipArchiveReader 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
-
prefersSeekableByteChannel
private boolean prefersSeekableByteChannel(java.lang.String format)
-
toPath
private java.nio.file.Path toPath(java.io.File targetDirectory)
-
-