public class ZipReader extends Object implements Closeable
Constructor and Description |
---|
ZipReader(File zipFile,
Charset charset)
构造
|
ZipReader(InputStream in,
Charset charset)
构造
|
ZipReader(ZipFile zipFile)
构造
|
ZipReader(ZipInputStream zin)
构造
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
InputStream |
get(String path)
获取指定路径的文件流
如果是文件模式,则直接获取Entry对应的流,如果是流模式,则遍历entry后,找到对应流返回 |
static ZipReader |
of(File zipFile,
Charset charset)
创建ZipReader
|
static ZipReader |
of(InputStream in,
Charset charset)
创建ZipReader
|
ZipReader |
read(Consumer<ZipEntry> consumer)
读取并处理Zip文件中的每一个
ZipEntry |
File |
readTo(File outFile)
解压到指定目录中
|
File |
readTo(File outFile,
Filter<ZipEntry> entryFilter)
解压到指定目录中
|
ZipReader |
setMaxSizeDiff(int maxSizeDiff)
设置检查ZipBomb文件差异倍数,-1表示不检查ZipBomb
|
public ZipReader(File zipFile, Charset charset)
zipFile
- 读取的的Zip文件charset
- 编码public ZipReader(ZipFile zipFile)
zipFile
- 读取的的Zip文件public ZipReader(InputStream in, Charset charset)
in
- 读取的的Zip文件流charset
- 编码public ZipReader(ZipInputStream zin)
zin
- 读取的的Zip文件流public static ZipReader of(File zipFile, Charset charset)
zipFile
- 生成的Zip文件charset
- 编码public static ZipReader of(InputStream in, Charset charset)
in
- Zip输入的流,一般为输入文件流charset
- 编码public ZipReader setMaxSizeDiff(int maxSizeDiff)
maxSizeDiff
- 检查ZipBomb文件差异倍数,-1表示不检查ZipBombpublic InputStream get(String path)
path
- 路径public File readTo(File outFile) throws IORuntimeException
outFile
- 解压到的目录IORuntimeException
- IO异常public File readTo(File outFile, Filter<ZipEntry> entryFilter) throws IORuntimeException
outFile
- 解压到的目录entryFilter
- 过滤器,排除不需要的文件IORuntimeException
- IO异常public ZipReader read(Consumer<ZipEntry> consumer) throws IORuntimeException
ZipEntry
consumer
- ZipEntry
处理器IORuntimeException
- IO异常public void close() throws IORuntimeException
close
in interface Closeable
close
in interface AutoCloseable
IORuntimeException
Copyright © 2024. All rights reserved.