文件压缩失败bug修改
parent
8174eac8d8
commit
67f30d793d
|
@ -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];
|
||||||
|
|
Loading…
Reference in New Issue