diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java index 8f41381..0d26163 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java @@ -117,23 +117,20 @@ public class FileUtils */ public static void urlResourceWriteBytes(List> filePathList, OutputStream os) throws IOException { -// InputStream fis = null; - BufferedInputStream buf = null; + BufferedInputStream bufIn = null; ZipEntry zipEntry = null; ZipOutputStream zipOutputStream = new ZipOutputStream(os); try { for(Map filePath:filePathList){ URL file = new URL(filePath.get("urlPath").toString()); -// fis = file.openStream(); - buf = new BufferedInputStream(file.openStream()); + bufIn = new BufferedInputStream(file.openStream()); zipEntry = new ZipEntry(filePath.get("downloadPath").toString()); zipOutputStream.putNextEntry(zipEntry); - byte[] b = new byte[1024]; - int length; - while ((length = buf.read(b)) > 0) + int length = 0; + while ((length = bufIn.read()) != -1) { - zipOutputStream.write(b, 0, length); + zipOutputStream.write(length); } } } @@ -145,8 +142,8 @@ public class FileUtils { zipOutputStream.closeEntry(); IOUtils.close(zipOutputStream); + IOUtils.close(bufIn); IOUtils.close(os); - IOUtils.close(buf); } }