zipoutputstream

create and download the Zip file java

こ雲淡風輕ζ 提交于 2021-02-07 07:08:00
问题 In my application there are no of documents(pdf) for a particular tender. I need to create a zip file from those pdf files and allow user to download it. Application is done in JavaEE with struts and mysql. when user clicks the download button this action class gets called. The code does not give any exceptions but it does not prompt user to download anything either. Please help me find what is wrong in the code. Following is the source code of my action class.. public class ActDownloadDocZip

create and download the Zip file java

心已入冬 提交于 2021-02-07 07:02:13
问题 In my application there are no of documents(pdf) for a particular tender. I need to create a zip file from those pdf files and allow user to download it. Application is done in JavaEE with struts and mysql. when user clicks the download button this action class gets called. The code does not give any exceptions but it does not prompt user to download anything either. Please help me find what is wrong in the code. Following is the source code of my action class.. public class ActDownloadDocZip

C# OutOfMemoryException creating ZipOutputStream using SharpZipLib

僤鯓⒐⒋嵵緔 提交于 2020-03-05 05:54:28
问题 I keep getting a very annoying OutOfMemory exception on the following code. I'm zipping a lot of small files (PDF, each being 1.5mb approx). At first I was getting the exception afer 25 files zipped, which doesn't seem like a massing archive. Setting up the size of the ZipEntry somehow helped since now I manage to get up to 110 files zipped (I'm debugging under visual studio) Here's my code, maybe there's something wrong with it. Any help would be greatly appreciated. Thanks public static

Removing a jar files META-INF folder in Java

家住魔仙堡 提交于 2020-02-04 14:41:02
问题 I am using the following method to filter out META-INF folder and its contents: public static void copyWithoutMetaInf(final String originalZip, final String newZip) throws IOException { final ZipInputStream zip = new ZipInputStream(new FileInputStream(originalZip)); final ZipOutputStream zop = new ZipOutputStream(new FileOutputStream(newZip)); ZipEntry entry; while((entry = zip.getNextEntry()) != null) { if(!entry.getName().contains("META-INF")) { zop.putNextEntry(entry); } } zip.close(); zop

Create one Zip file using a set of pdf files

余生颓废 提交于 2020-01-06 13:27:08
问题 My app is a tender document system where each tender number has one or more pdf files attached. application is done in java ee using struts and mysql. in a database table the paths of each related pdf file for a tender number is stores. I want to get all the pdf files and create a single ZIP file for each tender number so that user can download that zip file and have all the related documents in a single click. I tried Google and found something called ZipOutputStream but i cannot understand

ZipOutputStream - closeEntry() first or close() first

你离开我真会死。 提交于 2020-01-06 04:10:43
问题 Following is part of the some code. I need to close out resources in finally clause. Do I need to call closeEntry() first or close()? I am getting some error messages. Error closing the zipoutjava.io.IOException: Stream closed at java.util.zip.ZipOutputStream.ensureOpen(ZipOutputStream.java:70) at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:189) The code ZipOutputStream zos = null; try{ ZipEntry entry = new ZipEntry("file.csv") zipout.putNextEntry(entry); csvBeanWriter = new

Empty Folders are not adding to zip file android

房东的猫 提交于 2019-12-25 02:25:34
问题 I am doing an Android project. I need to zip a complete folder structure of SD card. code is able to zip the folder if any files exists inside the folder, else skips that folder. My Folder structure is like: mnt/sdcard/Movies/Telugu/Files. mnt/sdcard/Movies/English --> English is empty folder I did not see English folder in output zip file. My code: public void zip() { try { // create a ZipOutputStream to zip the data to ZipOutputStream zos = new ZipOutputStream(new FileOutputStream( _zipFile

Convert ZipOutputStream to ByteArrayInputStream

萝らか妹 提交于 2019-12-23 09:30:05
问题 I want to compress an InputStream using ZipOutputStream and then get the InputStream from compressed ZipOutputStream without saving file on disc. Is that possible? 回答1: I figured it out: public InputStream getCompressed( InputStream is ) throws IOException { byte data[] = new byte[2048]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream( bos ); BufferedInputStream entryStream = new BufferedInputStream( is, 2048); ZipEntry entry = new ZipEntry(

Java: ZipOutputStream to compress chunks of data to single zip file

丶灬走出姿态 提交于 2019-12-23 05:43:06
问题 Follow up of Question: Java: how to compress a byte[] using ZipOutputStream without intermediate file I can zip data without an intermediate file (or memory file). I now need to zip chunks of data and add them to a single zip file. I am using a single ZipOutputStream as suggested in the previous question. String infile = "test.txt"; FileInputStream in = new FileInputStream(infile); String outfile = "test.txt.zip"; FileOutputStream out = new FileOutputStream(outfile); ByteArrayOutputStream

Why do I have to close the ZipOutputStream in a certain way in this situation?

孤街醉人 提交于 2019-12-19 04:22:44
问题 I have two examples : Example 1: try (ByteArrayOutputStream baous = new ByteArrayOutputStream(); FileOutputStream fouscrx = new FileOutputStream(new File(output, "example"))) { try (ZipOutputStream zous = new ZipOutputStream(baous)) { for (File file: files) { try (FileInputStream fis = new FileInputStream(file)) { ZipEntry zipEntry = new ZipEntry(file.getPath().substring(output.getPath().length() + 1)); zous.putNextEntry(zipEntry); byte[] bytes = new byte[2048]; int length; while ((length =