public class StreamArchiver extends Object implements Archiver
ArchiveStreamFactory.AR
ArchiveStreamFactory.CPIO
ArchiveStreamFactory.JAR
ArchiveStreamFactory.TAR
ArchiveStreamFactory.ZIP
Constructor and Description |
---|
StreamArchiver(Charset charset,
String archiverName,
File file)
构造
|
StreamArchiver(Charset charset,
String archiverName,
OutputStream targetStream)
构造
|
Modifier and Type | Method and Description |
---|---|
StreamArchiver |
add(File file,
String path,
Filter<File> filter)
将文件或目录加入归档包,目录采取递归读取方式按照层级加入
|
void |
close()
无异常关闭
|
static StreamArchiver |
create(Charset charset,
String archiverName,
File file)
创建归档器
|
static StreamArchiver |
create(Charset charset,
String archiverName,
OutputStream out)
创建归档器
|
StreamArchiver |
finish()
结束已经增加的文件归档,此方法不会关闭归档流,可以继续添加文件
|
public StreamArchiver(Charset charset, String archiverName, File file)
charset
- 编码archiverName
- 归档类型名称,见ArchiveStreamFactory
file
- 归档输出的文件public StreamArchiver(Charset charset, String archiverName, OutputStream targetStream)
charset
- 编码archiverName
- 归档类型名称,见ArchiveStreamFactory
targetStream
- 归档输出的流public static StreamArchiver create(Charset charset, String archiverName, File file)
charset
- 编码archiverName
- 归档类型名称,见ArchiveStreamFactory
file
- 归档输出的文件public static StreamArchiver create(Charset charset, String archiverName, OutputStream out)
charset
- 编码archiverName
- 归档类型名称,见ArchiveStreamFactory
out
- 归档输出的流public StreamArchiver add(File file, String path, Filter<File> filter) throws IORuntimeException
add
in interface Archiver
file
- 文件或目录path
- 文件或目录的初始路径,null表示位于根路径filter
- 文件过滤器,指定哪些文件或目录可以加入,当Filter.accept(Object)
为true时加入。IORuntimeException
- IO异常public StreamArchiver finish()
Copyright © 2024. All rights reserved.