Hello, I would like to unzip a file, which I import in the application. I want to unzip the file and store the files and folders to the disk. How do I create a java action for the same? Kindly advice. Thanks in advance.
byte[] buffer = new byte[1024];
ZipInputStream zis = new ZipInputStream(Core.getFileDocumentContent(getContext(), __ParameterParameter1));
File folder = new File("C:\\outputzip1");
OutputStream outstream = new FileOutputStream(folder);
ZipEntry ze = zis.getNextEntry();
while(ze != null){
String filename = ze.getName();
File newFile = new File(outstream + File.separator + filename);
new File(newFile.getParent()).mkdirs();
OutputStream outstream1 = new FileOutputStream(newFile);
int len;
while ((len = zis.read(buffer)) > 0) {
outstream1.write(buffer, 0, len);
}
outstream1.close();
ze = zis.getNextEntry();
}
--Edit: shows, "java.security.AccessControlException: access denied ("java.io.FilePermission""C:\outputzip1""write")" error when executed. What exactly should I do? Thanks.