优化下载图片

master
gongzhenkun 2 years ago
parent a3226b3ebe
commit 8b019a4f44

@ -117,23 +117,20 @@ public class FileUtils
*/
public static void urlResourceWriteBytes(List<Map<String,Object>> 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<String,Object> 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);
}
}

Loading…
Cancel
Save