v0.0.1
Some checks failed
CI/CD / build-deploy (pull_request) Failing after 1m31s

This commit is contained in:
Timi
2026-04-01 14:09:24 +08:00
parent 47f1c9520e
commit afcc902cbf
20 changed files with 986 additions and 396 deletions

View File

@@ -1,14 +1,47 @@
package com.imyeyu.compress;
import com.imyeyu.io.IO;
import java.io.File;
import java.io.OutputStream;
/**
*
* 抽象压缩器
*
* @author 夜雨
* @version 2024-06-30 10:34
*/
public abstract class Compressor extends AbstractCompressor {
public abstract class Compressor extends AbstractRunner {
public abstract void run(String fromPath, File toFile) throws Exception;
/**
* 将指定路径下的文件压缩到目标文件
*
* @param fromPath 源路径
* @param toFile 目标压缩文件
* @throws Exception 压缩失败
*/
public void run(String fromPath, File toFile) throws Exception {
try (OutputStream outputStream = IO.getOutputStream(toFile)) {
run(fromPath, outputStream);
outputStream.flush();
} catch (Exception exception) {
if (isInterrupt) {
IO.destroy(toFile);
}
throw exception;
}
if (isInterrupt) {
IO.destroy(toFile);
}
}
/**
* 将指定路径下的文件压缩到输出流
* 输出流由调用方管理
*
* @param fromPath 源路径
* @param toStream 目标输出流
* @throws Exception 压缩失败
*/
public abstract void run(String fromPath, OutputStream toStream) throws Exception;
}