Module bus.extra

Interface Archiver

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
SevenZArchiver, StreamArchiver

public interface Archiver extends Closeable
Data archiving wrapper, which archives several files or directories into a compressed package.
Since:
Java 17+
Author:
Kimi Liu
  • Method Details

    • add

      default Archiver add(File file)
      Adds a file or directory to the archive. Directories are added recursively level by level.
      Parameters:
      file - The file or directory.
      Returns:
      this
    • add

      default Archiver add(File file, Predicate<File> filter)
      Adds a file or directory to the archive. Directories are added recursively level by level.
      Parameters:
      file - The file or directory.
      filter - A file filter that specifies which files or directories can be added. If Predicate.test(Object) is true, the file is added. If null, all are added.
      Returns:
      this
    • add

      default Archiver add(File file, String path, Predicate<File> filter)
      Adds a file or directory to the archive package. Directories are added recursively level by level.
      Parameters:
      file - The file or directory.
      path - The initial path of the file or directory. If null, it is placed at the root level.
      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
    • add

      Archiver add(File file, String path, Function<String,String> fileNameEditor, Predicate<File> filter)
      Adds a file or directory to the archive package. Directories are added recursively level by level.
      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

      Archiver finish()
      Finishes archiving the added files. This method does not close the archive stream, allowing more files to be added.
      Returns:
      this
    • close

      void close()
      Closes without throwing an exception.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable