Solved

util.zip package

Posted on 1998-05-28
1
148 Views
Last Modified: 2010-04-16
Has anyone worked with the util.zip package? I´m trying to compress with it some images that I have in a int which I obtain after using PixelGrabber.

I have tried with classes Deflater and Inflater, but with a very simple example they don't seem to work properly.

Any example would be very helpful

Thanks in advance
0
Comment
Question by:Jose Luis
1 Comment
 

Accepted Solution

by:
muesli earned 100 total points
ID: 1221641
The easiest way to use the compression that comes with Java is to use the classes:

GZIPInputStream, GZIPOutputStream, ZipInputStream, ZipOutputStream.

For example, let's say you're saving the image data to a file.  At some point in your code you've got something like this:

OutputStream out = new FileOutputStream( filename );

Replace it with the following:

OutputStream out = new ZipOutputSream(
                         new FileOutputStream( filename ) );

...and then you just use "out" as you normally would. (Wrapping it in a BufferedOutputStream, for example.)

This works analagously for InputStreams, as well as for streams other then FilexxxStream.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jsp login check 12 54
Html Table Looping (part 2) 5 35
American Express @Work site and Java 4 69
netbeans can not run self signed app 8 14
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question