Pessoal
Meu fileUpload(primefaces) esta funcionando perfeitamente. Ele cria a pasta e coloca os arquivos dentro, tudo certo.
O que eu quero é zipar essa pasta. Como eu poderia fazer isso ?
public void upload(FileUploadEvent event) {
FacesMessage msg = new FacesMessage("Sucesso! ", event.getFile().getFileName() + " foi enviado.");
FacesContext.getCurrentInstance().addMessage(null, msg);
// Do what you want with the file
try {
copyFile(event.getFile().getFileName(), event.getFile().getInputstream());
} catch (IOException e) {
e.printStackTrace();
}
}
public void copyFile(String fileName, InputStream in) {
try {
//write the inputStream to a FileOutputStream
File diretorio = new File("P:\\arquivos_tecnico_sig\\"+getDocumentoTecnico().getDocumento()+"\\");
diretorio.mkdir();
OutputStream out = new FileOutputStream(new File("P:\\arquivos_tecnico_sig\\"+getDocumentoTecnico().getDocumento()+"\\" + fileName));
int read = 0;
byte[] bytes = new byte[1024];
while ((read = in.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
in.close();
out.flush();
out.close();
System.out.println("New file created!");
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
