• Post Reply Bookmark Topic Watch Topic
  • New Topic

zipping file  RSS feed

 
biswajit goswami
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a byte array needs to be zipped and returned, without making use of intermediate temporary file.......i am able to zip as follows:


ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName.toString()));
FileInputStream fileStream = new FileInputStream(newFile);
out.putNextEntry(new ZipEntry(zipFileName.toString()));
int len;
while((len = fileStream.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.closeEntry();
fileStream.close();

out.close();
then read the zipped file

in doing so i am first making a zipped file and then reading that file to retrieve the zipped byte array.i dont want this intermediate file to be created and still be able to get the byte array.Any help welcome
 
Joe Ess
Bartender
Posts: 9436
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use ByteArrayOutputStream rather than FileOutputStream.
 
biswajit goswami
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.........
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!