zipoutputstream

Reading from a ZipInputStream into a ByteArrayOutputStream

女生的网名这么多〃 提交于 2019-12-03 04:57:17
I am trying to read a single file from a java.util.zip.ZipInputStream , and copy it into a java.io.ByteArrayOutputStream (so that I can then create a java.io.ByteArrayInputStream and hand that to a 3rd party library that will end up closing the stream, and I don't want my ZipInputStream getting closed). I'm probably missing something basic here, but I never enter the while loop here: ByteArrayOutputStream streamBuilder = new ByteArrayOutputStream(); int bytesRead; byte[] tempBuffer = new byte[8192*2]; try { while ((bytesRead = zipStream.read(tempBuffer)) != -1) { streamBuilder.write(tempBuffer

Zip subfolders using ZipOutputStream

别说谁变了你拦得住时间么 提交于 2019-11-30 21:45:55
ZipOutputStream only zips files in a folder. I want to zip subfolders also. How can I achieve this? You have to recursively explore your directory in order to add all files in the zip. See this small helper if you wish: using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Checksums; using System.IO; using System; using System.Collections.Generic; using System.Text; using System.Collections; using System.Text.RegularExpressions; namespace Zip { /// <summary> /// Uses Sharpziplib so as to create a non flat zip archive /// </summary> public abstract class ZipManager { /// <summary> //

How to encrypt a ZipOutputStream in Google appengine?

限于喜欢 提交于 2019-11-30 00:08:04
问题 I am creating zip files in GAE with Java, using ZipOutputStream to upload them to Google Cloud Storage. However I need to encrypt the files but I don't know how. Does anyone know how to encrypt a ZipOutputStream in Google Appengine? 回答1: Below is a sample Java application that demonstrates writing a block of text to a DES-encrypted file inside a zip archive. The output of the app: CloudStorageZipCrypto GET starting. Creating file... File created. Writing to file: /gs/writable:<snipped> Wrote

Spring REST - create .zip file and send it to the client

本秂侑毒 提交于 2019-11-27 13:30:01
I want to create .zip file that contains my zipped files that I recieve from backend, and then send this file to the user. For 2 days I have been looking for the answer and cant find proper solution, maybe you can help me :) For now, the code is like this: (I know I shouldnt do it all in the spring controller, but dont care about that, it is just for testing purposes, to find the way to make it works) @RequestMapping(value = "/zip") public byte[] zipFiles(HttpServletResponse response) throws IOException{ //setting headers response.setContentType("application/zip"); response.setStatus

How to create a zip file of multiple image files

天涯浪子 提交于 2019-11-27 02:24:19
问题 I am trying to create a zip file of multiple image files. I have succeeded in creating the zip file of all the images but somehow all the images have been hanged to 950 bytes. I don't know whats going wrong here and now I can't open the images were compressed into that zip file. Here is my code. Can anyone let me know what's going here? String path="c:\\windows\\twain32"; File f=new File(path); f.mkdir(); File x=new File("e:\\test"); x.mkdir(); byte []b; String zipFile="e:\\test\\test.zip";

Spring REST - create .zip file and send it to the client

情到浓时终转凉″ 提交于 2019-11-26 22:49:58
问题 I want to create .zip file that contains my zipped files that I recieve from backend, and then send this file to the user. For 2 days I have been looking for the answer and cant find proper solution, maybe you can help me :) For now, the code is like this: (I know I shouldnt do it all in the spring controller, but dont care about that, it is just for testing purposes, to find the way to make it works) @RequestMapping(value = "/zip") public byte[] zipFiles(HttpServletResponse response) throws

Adding files to ZIP file

懵懂的女人 提交于 2019-11-26 21:44:31
问题 I am trying to add some files to a ZIP file, it creates the file but does not add anything into it. Code 1: String fulldate = year + "-" + month + "-" + day + "-" + min; File dateFolder = new File("F:\\" + compname + "\\" + fulldate); dateFolder.mkdir(); String zipName = "F:\\" + compname + "\\" + fulldate + "\\" + fulldate + ".zip"; zipFolder(tobackup, zipName); My function: public static void zipFolder(File folder, String name) throws Exception { byte[] buffer = new byte[18024];