Solved

util.zip package

Posted on 1998-05-28
1
144 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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now