mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix ZipUtil
This commit is contained in:
parent
d2ec0b2bdb
commit
a0f5970037
@ -15,6 +15,7 @@
|
||||
* 【core 】 修复StrUtil.brief长度问题(pr#930@Github)
|
||||
* 【socket 】 修复AioSession构造超时无效问题(pr#941@Github)
|
||||
* 【setting】 修复GroupSet.contains错误(pr#943@Github)
|
||||
* 【core 】 修复ZipUtil没有调用finish问题(issue#944@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
## 5.3.8 (2020-06-16)
|
||||
|
@ -228,6 +228,7 @@ public class ZipUtil {
|
||||
// 调用递归压缩方法进行目录或文件压缩
|
||||
zip(srcFile, srcRootDir, zipOutputStream, filter);
|
||||
zipOutputStream.flush();
|
||||
zipOutputStream.finish();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
|
@ -7,6 +7,9 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* {@link ZipUtil}单元测试
|
||||
@ -89,4 +92,18 @@ public class ZipUtilTest {
|
||||
//保证正常还原
|
||||
Assert.assertEquals(data, StrUtil.utf8Str(unGzip2));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void zipStreamTest(){
|
||||
//https://github.com/looly/hutool/issues/944
|
||||
String dir = "d:/test";
|
||||
String zip = "d:/test.zip";
|
||||
try (OutputStream out = new FileOutputStream(zip)){
|
||||
//实际应用中, out 为 HttpServletResponse.getOutputStream
|
||||
ZipUtil.zip(out, Charset.defaultCharset(), false, null, new File(dir));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user