Alguem poderia me ajudar a descompactar um arquivo .zip
, pois compactar eu consegui porém tive problemas em descompactar. Segue o codigo de compactacao …
public static byte[] compactar(byte[] fileIn, String fileName) {
ByteArrayOutputStream fileOut = null;
try {
// Cria o ZIP e o Stream de saída
fileOut = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(fileOut);
//Adiciona o arquivo no zip
zip.putNextEntry(new ZipEntry(fileName));
zip.write(fileIn);
zip.closeEntry();
zip.close();
} catch (Exception e) {
e.printStackTrace();
}
//Retorna os bytes do ZIP
return fileOut.toByteArray();
}