Aggiunto extractZipFile
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -4,6 +4,7 @@ import it.integry.ems.response.FileItem;
|
|||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.zip.*;
|
import java.util.zip.*;
|
||||||
|
|
||||||
@@ -131,4 +132,26 @@ public class UtilityZip {
|
|||||||
|
|
||||||
return outputStream.toByteArray();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user