Module bus.extra

Class SevenZArchiver

java.lang.Object
org.miaixz.bus.extra.compress.archiver.SevenZArchiver
All Implemented Interfaces:
Closeable, AutoCloseable, Archiver

public class SevenZArchiver extends Object implements Archiver
7zip format archiver wrapper.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • SevenZArchiver

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

      public SevenZArchiver(OutputStream out)
      Constructor.
      Parameters:
      out - The archive output stream.
    • SevenZArchiver

      public SevenZArchiver(SeekableByteChannel channel)
      Constructor.
      Parameters:
      channel - The archive output channel.
  • Method Details

    • getSevenZOutputFile

      public org.apache.commons.compress.archivers.sevenz.SevenZOutputFile getSevenZOutputFile()
      Gets the SevenZOutputFile to allow for custom settings.
      Returns:
      The SevenZOutputFile.
    • add

      public SevenZArchiver add(File file, String path, Function<String,String> fileNameEditor, Predicate<File> filter)
      Description copied from interface: Archiver
      Adds a file or directory to the archive package. Directories are added recursively level by level.
      Specified by:
      add in interface Archiver
      Parameters:
      file - The file or directory.
      path - The initial path of the file or directory. If null, it is placed at the root level.
      fileNameEditor - A function to edit the file name.
      filter - A file filter that specifies which files or directories can be added. If Predicate.test(Object) is true, the file is kept. If null, all are added.
      Returns:
      this
    • finish

      public SevenZArchiver finish()
      Description copied from interface: Archiver
      Finishes archiving the added files. This method does not close the archive stream, allowing more files to be added.
      Specified by:
      finish in interface Archiver
      Returns:
      this
    • close

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