java.lang.Object
org.miaixz.bus.extra.compress.extractor.SevenZExtractor
- All Implemented Interfaces:
Closeable,AutoCloseable,RandomAccess,Extractor
Extractor for 7z format archives, used to unpack archived data.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionSevenZExtractor(File file) Constructor.SevenZExtractor(File file, char[] password) Constructor.Constructor.SevenZExtractor(InputStream in, char[] password) Constructor.SevenZExtractor(SeekableByteChannel channel) Constructor.SevenZExtractor(SeekableByteChannel channel, char[] password) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes without throwing an exception.voidExtracts (decompresses) to the specified directory.Gets the first file stream in the compressed package that meets the specified filter requirements.
-
Constructor Details
-
SevenZExtractor
Constructor.- Parameters:
file- The archive file.
-
SevenZExtractor
Constructor.- Parameters:
file- The archive file.password- The password, null for no password.
-
SevenZExtractor
Constructor.- Parameters:
in- The archive stream.
-
SevenZExtractor
Constructor.- Parameters:
in- The archive stream.password- The password, null for no password.
-
SevenZExtractor
Constructor.- Parameters:
channel-SeekableByteChannel.
-
SevenZExtractor
Constructor.- Parameters:
channel-SeekableByteChannel.password- The password, null for no password.
-
-
Method Details
-
extract
public void extract(File targetDir, Predicate<org.apache.commons.compress.archivers.ArchiveEntry> predicate) Description copied from interface:ExtractorExtracts (decompresses) to the specified directory. The stream is automatically closed after completion. This method can only be called once.- Specified by:
extractin interfaceExtractor- Parameters:
targetDir- The target directory.predicate- A filter for extracted files, used to specify which files to extract.nullmeans no filtering. Extracts whenPredicate.test(Object)istrue.
-
getFirst
public InputStream getFirst(Predicate<org.apache.commons.compress.archivers.ArchiveEntry> predicate) Description copied from interface:ExtractorGets the first file stream in the compressed package that meets the specified filter requirements.- Specified by:
getFirstin interfaceExtractor- Parameters:
predicate- Used to specify the files to be extracted. null means no filtering. Returns the corresponding stream whenPredicate.test(Object)istrue.- Returns:
- The stream of the first file that meets the filter requirements, or
nullif no matching file is found.
-
close
public void close()Description copied from interface:ExtractorCloses without throwing an exception.
-