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 c48d6bf..0de682d 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 @@ -24,6 +24,8 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.uuid.IdUtils; import org.apache.commons.io.FilenameUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import sun.misc.BASE64Decoder; /** @@ -33,6 +35,8 @@ import sun.misc.BASE64Decoder; */ public class FileUtils { + private static final Logger logger = LoggerFactory.getLogger(FileUtils.class); + public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; /** @@ -210,17 +214,15 @@ public class FileUtils fileOut = new FileOutputStream(desc); zipOutputStream = new ZipOutputStream(fileOut); for(Map filePath:filePathList){ - URL file = new URL(filePath.get("urlPath").toString()); - bufIn = new BufferedInputStream(file.openStream()); - zipEntry = new ZipEntry(filePath.get("downloadPath").toString()); - zipOutputStream.putNextEntry(zipEntry); -// byte[] b = new byte[1024*4]; -// int length; -// while ((length = bufIn.read(b)) > 0) -// { -// zipOutputStream.write(b, 0, length); -// } - IOUtils.copy(bufIn,zipOutputStream); + try{ + URL file = new URL(filePath.get("urlPath").toString()); + bufIn = new BufferedInputStream(file.openStream()); + zipEntry = new ZipEntry(filePath.get("downloadPath").toString()); + zipOutputStream.putNextEntry(zipEntry); + IOUtils.copy(bufIn,zipOutputStream); + }catch (Exception ee){ + logger.error("downloadLocalZip方法图片下载失败,"+filePath.get("urlPath").toString()+"地址的图片访问失败",ee); + } } } catch (IOException e)