copy is an array of strings which contain the file path for each file I want (for example C:\files\test.pdf, I have tested it yes the correct values are in it). It compiles and runs fine with no exceptions and creates the zip folder, but nothing is in said zip folder.Code:byte[] buf = new byte[1024];//time to make zip file String zipName="name.zip"; ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipName)); for(int i=0; i<copy.length; i++){//put all pdfs in the zip FileInputStream zipFile = new FileInputStream(copy[i]); out.putNextEntry(new ZipEntry(copy[i])); int len; while((len=zipFile.read(buf))>0){ out.write(buf, 0, len); } out.closeEntry(); zipFile.close(); } out.close();
Note, I also have an array of files (which I used to fill copy using toString) if that would be easier. ZipEntry only seems to accept strings which is why I tried to do it this way.


Reply With Quote
Bookmarks