- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
SevenZArchiver,StreamArchiver
Data archiving wrapper, which archives several files or directories into a compressed package.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Method Summary
Modifier and TypeMethodDescriptiondefault ArchiverAdds a file or directory to the archive.Adds a file or directory to the archive package.default ArchiverAdds a file or directory to the archive package.default ArchiverAdds a file or directory to the archive.voidclose()Closes without throwing an exception.finish()Finishes archiving the added files.
-
Method Details
-
add
Adds a file or directory to the archive. Directories are added recursively level by level.- Parameters:
file- The file or directory.- Returns:
- this
-
add
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. IfPredicate.test(Object)istrue, the file is added. If null, all are added.- Returns:
- this
-
add
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. IfPredicate.test(Object)istrue, 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. IfPredicate.test(Object)istrue, 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-