Oi Pessoal.
Estou precisando compactar alguns arquivos e a compactação ocorre, mas compacta dois arquivos, que disponibilizei para testes, com apenas 1Kb. Ou seja, tem alguma coisa errada nesta compactação. Os arquivos estão sendo todos corrompidos. Há alguém que posso ajudar ?
Segue parte do código abaixo.
Obrigado.
//Compactação do arquivo
byte[] buf = new byte[1024];
try {
// Create the ZIP file
ZipOutputStream out = new ZipOutputStream(new FileOutputStream("\\home\\mbbj\\arquivo\\ARQUIVOZIP.zip"));
// Compress the files
for (int i = 0; i < projeto.getArquivos().size(); i++) {
FileInputStream in = new FileInputStream("\\home\\mbbj\\arquivo\\ARQUIVOZIP.zip");
// Add ZIP entry to output stream.
out.putNextEntry(new ZipEntry(arquivosEleitosParaCompactacao[i]));
// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
// Complete the entry
out.closeEntry();
in.close();
}
// Complete the ZIP file
out.close();
} catch (IOException e) {
}