Solved

util.zip package

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Timer (static) 9 45
table example 4 29
servlet example issue 6 40
CSV file parsing thru Java 13 31
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

831 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