Solved

util.zip package

Posted on 1998-05-28
1
147 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
null output 3 35
jsp login check 12 42
jboss 7.1 start up error 1 28
Running JavaFX on the Raspberry Pi 27 35
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

790 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