Module bus.extra

Class SevenZExtractor

java.lang.Object
org.miaixz.bus.extra.compress.extractor.SevenZExtractor
All Implemented Interfaces:
Closeable, AutoCloseable, RandomAccess, Extractor

public class SevenZExtractor extends Object implements Extractor, RandomAccess
Extractor for 7z format archives, used to unpack archived data.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • SevenZExtractor

      public SevenZExtractor(File file)
      Constructor.
      Parameters:
      file - The archive file.
    • SevenZExtractor

      public SevenZExtractor(File file, char[] password)
      Constructor.
      Parameters:
      file - The archive file.
      password - The password, null for no password.
    • SevenZExtractor

      public SevenZExtractor(InputStream in)
      Constructor.
      Parameters:
      in - The archive stream.
    • SevenZExtractor

      public SevenZExtractor(InputStream in, char[] password)
      Constructor.
      Parameters:
      in - The archive stream.
      password - The password, null for no password.
    • SevenZExtractor

      public SevenZExtractor(SeekableByteChannel channel)
      Constructor.
      Parameters:
      channel - SeekableByteChannel.
    • SevenZExtractor

      public SevenZExtractor(SeekableByteChannel channel, char[] password)
      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: Extractor
      Extracts (decompresses) to the specified directory. The stream is automatically closed after completion. This method can only be called once.
      Specified by:
      extract in interface Extractor
      Parameters:
      targetDir - The target directory.
      predicate - A filter for extracted files, used to specify which files to extract. null means no filtering. Extracts when Predicate.test(Object) is true.
    • getFirst

      public InputStream getFirst(Predicate<org.apache.commons.compress.archivers.ArchiveEntry> predicate)
      Description copied from interface: Extractor
      Gets the first file stream in the compressed package that meets the specified filter requirements.
      Specified by:
      getFirst in interface Extractor
      Parameters:
      predicate - Used to specify the files to be extracted. null means no filtering. Returns the corresponding stream when Predicate.test(Object) is true.
      Returns:
      The stream of the first file that meets the filter requirements, or null if no matching file is found.
    • close

      public void close()
      Description copied from interface: Extractor
      Closes without throwing an exception.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Extractor