Class Compressor<T extends Compressor<T>>

java.lang.Object
com.imyeyu.compress.AbstractRunner<T>
com.imyeyu.compress.Compressor<T>
Type Parameters:
T - 压缩器类型
All Implemented Interfaces:
com.imyeyu.utils.OS.FileSystem
Direct Known Subclasses:
GZipCompressor, TarCompressor, Z7Compressor, ZipCompressor

public abstract class Compressor<T extends Compressor<T>> extends AbstractRunner<T>
抽象压缩器
Version:
2024-06-30 10:34
Author:
夜雨
  • Constructor Details

    • Compressor

      public Compressor()
  • Method Details

    • of

      protected T of(String fromPath)
      绑定源路径
      Parameters:
      fromPath - 源路径
      Returns:
      当前压缩器
    • of

      protected T of(File fromFile)
      绑定源文件
      Parameters:
      fromFile - 源文件
      Returns:
      当前压缩器
    • toFile

      public T toFile(File toFile) throws Exception
      压缩到目标文件
      Parameters:
      toFile - 目标压缩文件
      Returns:
      当前压缩器
      Throws:
      Exception - 压缩失败
    • toFile

      public T toFile(String toPath) throws Exception
      压缩到目标文件路径
      Parameters:
      toPath - 目标压缩文件路径
      Returns:
      当前压缩器
      Throws:
      Exception - 压缩失败
    • toStream

      public T toStream(OutputStream toStream) throws Exception
      压缩到输出流 输出流由调用方管理
      Parameters:
      toStream - 目标输出流
      Returns:
      当前压缩器
      Throws:
      Exception - 压缩失败
    • requireFromPath

      protected String requireFromPath()
      获取已绑定的源路径
      Returns:
      源路径
    • toFile

      protected void toFile(String fromPath, File toFile) throws Exception
      执行压缩到目标文件
      Parameters:
      fromPath - 源路径
      toFile - 目标压缩文件
      Throws:
      Exception - 压缩失败
    • toStream

      protected abstract void toStream(String fromPath, OutputStream toStream) throws Exception
      执行压缩到输出流
      Parameters:
      fromPath - 源路径
      toStream - 目标输出流
      Throws:
      Exception - 压缩失败