Ho la necessita’ di creare un file zip con file prelevati dal Database (attraverso oggetti CLob)… e in questo modo riesco a creare lo zip:
il problema e’ che essendo un’applicazione Web, non posso scrivere il file (.zip) su File System !!! Il file zip lo devo salvare sul Database!codice:byte[] buffer = new byte[18024]; ZipOutputStream out = new ZipOutputStream( new BufferedOutputStream(new FileOutputStream(nomeFileZip+".zip"))); // Set the compression ratio out.setLevel(Deflater.DEFAULT_COMPRESSION); for (int i = 0; i < comunicazione.size(); i++) { InputStream file =(InputStream) comunicazione.get(i); // Associate a file input stream for the current file ZipEntry zip = new ZipEntry(nomeFileZip+"_"+i+".html"); // Add ZIP entry to output stream. out.putNextEntry(zip); // Transfer bytes from the current file to the ZIP file int len; while ((len = file.read(buffer)) > 0) { out.write( buffer, 0, len); } // Close the current entry out.closeEntry(); } // Close the ZipOutPutStream out.close();
Consigli???
Grazie
Francesco

Rispondi quotando