文件压缩失败bug修改

limingyu-20240401-app登录曹实业判断修改
liujun 2024-02-26 18:26:23 +08:00
parent 8174eac8d8
commit 67f30d793d
1 changed files with 7 additions and 2 deletions

View File

@ -373,10 +373,15 @@ public class Warden {
FileInputStream fileInputStream; FileInputStream fileInputStream;
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
try (ZipOutputStream zipOut = new ZipOutputStream(byteOutStream)) { try (ZipOutputStream zipOut = new ZipOutputStream(byteOutStream)) {
String fileNames = "";
Random random = new Random();
for (File file : srcFiles) { for (File file : srcFiles) {
fileInputStream = new FileInputStream(file); fileInputStream = new FileInputStream(file);
ZipEntry zipEntry = new ZipEntry(file.getName()); String fileName = file.getName();
if (fileNames.contains(fileName)){
fileName = (random.nextInt(90000) + 10000) + fileName;
}
ZipEntry zipEntry = new ZipEntry(fileName);
zipOut.putNextEntry(zipEntry); zipOut.putNextEntry(zipEntry);
int len; int len;
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];