mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
add exception
This commit is contained in:
parent
58441b393f
commit
93951af07e
@ -388,7 +388,8 @@ public class ZipUtil {
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public static File unzip(File zipFile, Charset charset) throws UtilException {
|
||||
return unzip(zipFile, FileUtil.file(zipFile.getParentFile(), FileUtil.mainName(zipFile)), charset);
|
||||
final File destDir = FileUtil.file(zipFile.getParentFile(), FileUtil.mainName(zipFile));
|
||||
return unzip(zipFile, destDir, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -459,6 +460,9 @@ public class ZipUtil {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static File unzip(ZipFile zipFile, File outFile) throws IORuntimeException {
|
||||
if(outFile.exists() && outFile.isFile()){
|
||||
throw new UtilException("Target path [{}] exist!", outFile.getAbsolutePath());
|
||||
}
|
||||
try {
|
||||
final Enumeration<ZipEntry> em = (Enumeration<ZipEntry>) zipFile.entries();
|
||||
ZipEntry zipEntry;
|
||||
|
@ -1,13 +1,12 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* {@link ZipUtil}单元测试
|
||||
@ -36,7 +35,7 @@ public class ZipUtilTest {
|
||||
File unzip = ZipUtil.unzip("f:/test/各种资源.zip", "f:/test/各种资源", CharsetUtil.CHARSET_GBK);
|
||||
Console.log(unzip);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void unzipFromStreamTest() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user