Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

zipping file

 
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
 
Bartender
Posts: 9559
12
Mac OS X Linux 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.........
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!