|
|
@@ -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();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|