public class ZipReader extends Object implements Closeable
| Constructor and Description |
|---|
ZipReader(ZipFile zipFile)
构造
|
ZipReader(ZipInputStream zin)
构造
|
ZipReader(ZipResource resource)
构造
|
| 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,
Predicate<ZipEntry> entryFilter)
解压到指定目录中
|
ZipReader |
setMaxSizeDiff(int maxSizeDiff)
设置检查ZipBomb文件差异倍数,-1表示不检查ZipBomb
|
public ZipReader(ZipFile zipFile)
zipFile - 读取的的Zip文件public ZipReader(ZipInputStream zin)
zin - 读取的的Zip文件流public ZipReader(ZipResource resource)
resource - 读取的的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, Predicate<ZipEntry> entryFilter) throws IORuntimeException
outFile - 解压到的目录entryFilter - 过滤器,只保留Predicate.test(Object)结果为true的文件IORuntimeException - IO异常public ZipReader read(Consumer<ZipEntry> consumer) throws IORuntimeException
ZipEntryconsumer - ZipEntry处理器IORuntimeException - IO异常public void close()
throws IORuntimeException
close in interface Closeableclose in interface AutoCloseableIORuntimeExceptionCopyright © 2025. All rights reserved.