This commit is contained in:
@@ -1,21 +1,38 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 抽象解压
|
||||
* 抽象解压器
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 18:02
|
||||
*/
|
||||
public abstract class Decompressor extends AbstractCompressor {
|
||||
public abstract class Decompressor extends AbstractRunner {
|
||||
|
||||
/**
|
||||
* 执行解压
|
||||
* 将压缩文件解压到目标目录
|
||||
*
|
||||
* @param fromFile 来源压缩文件
|
||||
* @param toPath 解压路径
|
||||
* @param fromFile 源压缩文件
|
||||
* @param toPath 目标目录
|
||||
* @throws Exception 解压失败
|
||||
*/
|
||||
public abstract void run(File fromFile, String toPath) throws Exception;
|
||||
public void run(File fromFile, String toPath) throws Exception {
|
||||
try (InputStream inputStream = IO.getInputStream(fromFile)) {
|
||||
run(inputStream, toPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将压缩输入流解压到目标目录
|
||||
* 输入流由调用方管理
|
||||
*
|
||||
* @param fromStream 源压缩输入流
|
||||
* @param toPath 目标目录
|
||||
* @throws Exception 解压失败
|
||||
*/
|
||||
public abstract void run(InputStream fromStream, String toPath) throws Exception;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user