浏览代码

fix #I2B0S1

Looly 5 年之前
父节点
当前提交
7d25da459f

+ 2 - 1
CHANGELOG.md

@@ -3,12 +3,13 @@
 
 -------------------------------------------------------------------------------------------------------------
 
-# 5.5.6 (2020-12-28)
+# 5.5.6 (2020-12-29)
 
 ### 新特性
 * 【core   】     手机号工具类 座机正则表达式统一管理(pr#243@Gitee)
 
 ### Bug修复
+* 【core   】     修复ZipUtil.unzip从流解压关闭问题(issue#I2B0S1@Gitee)
 
 -------------------------------------------------------------------------------------------------------------
 

+ 14 - 1
hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java

@@ -2914,7 +2914,20 @@ public class FileUtil extends PathUtil {
 	 * @throws IORuntimeException IO异常
 	 */
 	public static File writeFromStream(InputStream in, File dest) throws IORuntimeException {
-		return FileWriter.create(dest).writeFromStream(in);
+		return writeFromStream(in, dest, true);
+	}
+
+	/**
+	 * 将流的内容写入文件
+	 *
+	 * @param dest 目标文件
+	 * @param in   输入流
+	 * @return dest
+	 * @throws IORuntimeException IO异常
+	 * @since 5.5.6
+	 */
+	public static File writeFromStream(InputStream in, File dest, boolean isCloseIn) throws IORuntimeException {
+		return FileWriter.create(dest).writeFromStream(in, isCloseIn);
 	}
 
 	/**

+ 1 - 1
hutool-core/src/main/java/cn/hutool/core/util/ZipUtil.java

@@ -644,7 +644,7 @@ public class ZipUtil {
 				outItemFile.mkdirs();
 			} else {
 				// 文件
-				FileUtil.writeFromStream(zipStream, outItemFile);
+				FileUtil.writeFromStream(zipStream, outItemFile, false);
 			}
 		});
 		return outFile;

+ 1 - 1
hutool-extra/src/main/java/cn/hutool/extra/compress/extractor/StreamExtractor.java

@@ -119,7 +119,7 @@ public class StreamExtractor implements Extractor{
 				//noinspection ResultOfMethodCallIgnored
 				outItemFile.mkdirs();
 			} else {
-				FileUtil.writeFromStream(in, outItemFile);
+				FileUtil.writeFromStream(in, outItemFile, false);
 			}
 		}
 	}