Aggiunto extractZipFile
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-04-17 10:59:49 +02:00
parent 2dfd120b54
commit 841ab996b1

View File

@@ -4,6 +4,7 @@ import it.integry.ems.response.FileItem;
import org.apache.commons.io.FilenameUtils;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.*;
@@ -131,4 +132,26 @@ public class UtilityZip {
return outputStream.toByteArray();
}
public static List<byte[]> extractZipFile(byte[] zipFile) throws Exception {
List<byte[]> extractedFiles = new ArrayList<>();
ByteArrayInputStream inputStream = new ByteArrayInputStream(zipFile);
ZipInputStream zipInputStream = new ZipInputStream(inputStream);
while (zipInputStream.getNextEntry() != null) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = zipInputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, len);
}
extractedFiles.add(outputStream.toByteArray());
zipInputStream.closeEntry();
outputStream.close();
}
zipInputStream.close();
inputStream.close();
return extractedFiles;
}
}