类 ZipReader

java.lang.Object
com.luna.common.file.compress.ZipReader
所有已实现的接口:
Closeable, AutoCloseable

public class ZipReader extends Object implements Closeable
Zip文件或流读取器,一般用于Zip文件解压
从以下版本开始:
5.7.8
作者:
looly
  • 构造器详细资料

    • ZipReader

      public ZipReader(File zipFile, Charset charset)
      构造
      参数:
      zipFile - 读取的的Zip文件
      charset - 编码
    • ZipReader

      public ZipReader(ZipFile zipFile)
      构造
      参数:
      zipFile - 读取的的Zip文件
    • ZipReader

      public ZipReader(InputStream in, Charset charset)
      构造
      参数:
      in - 读取的的Zip文件流
      charset - 编码
    • ZipReader

      public ZipReader(ZipInputStream zin)
      构造
      参数:
      zin - 读取的的Zip文件流
  • 方法详细资料

    • of

      public static ZipReader of(File zipFile, Charset charset)
      创建ZipReader
      参数:
      zipFile - 生成的Zip文件
      charset - 编码
      返回:
      ZipReader
    • of

      public static ZipReader of(InputStream in, Charset charset)
      创建ZipReader
      参数:
      in - Zip输入的流,一般为输入文件流
      charset - 编码
      返回:
      ZipReader
    • get

      public InputStream get(String path) throws IOException
      获取指定路径的文件流
      如果是文件模式,则直接获取Entry对应的流,如果是流模式,则遍历entry后,找到对应流返回
      参数:
      path - 路径
      返回:
      文件流
      抛出:
      IOException
    • readTo

      public File readTo(File outFile) throws IOException
      解压到指定目录中
      参数:
      outFile - 解压到的目录
      返回:
      解压的目录
      抛出:
      IOException - IO异常
    • readTo

      public File readTo(File outFile, Filter<ZipEntry> entryFilter) throws IOException
      解压到指定目录中
      参数:
      outFile - 解压到的目录
      entryFilter - 过滤器,排除不需要的文件
      返回:
      解压的目录
      抛出:
      IOException - IO异常
      从以下版本开始:
      5.7.12
    • read

      public ZipReader read(java.util.function.Consumer<ZipEntry> consumer) throws IOException
      读取并处理Zip文件中的每一个ZipEntry
      参数:
      consumer - ZipEntry处理器
      返回:
      this
      抛出:
      IOException - IO异常
    • close

      public void close() throws IOException
      指定者:
      close 在接口中 AutoCloseable
      指定者:
      close 在接口中 Closeable
      抛出:
      IOException