You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
General <strong>Java</strong> Questions IV<br />
Receive our newsletter with new tips! Almost 6,000 subscribers (by June 2001) can not be wrong!<br />
They read our tips every week! To subscribe to The <strong>Java</strong> FAQ Daily send empty e-mail to:<br />
javafaq-tips-subscribe@topica.com or visit at:<br />
http://www.topica.com/lists/javafaq-tips/<br />
General <strong>Java</strong> Questions IV<br />
Q: I am looking for more efficient compression APIs esp. for *.doc and *.html<br />
files.<br />
I need some <strong>Java</strong> APIs wherein I can implement various compression algorithms. I<br />
have already the GZIP compression technique shipped with JDK's java.util.zip<br />
package. I am looking for more efficient compression APIs esp. for *.doc and *.html<br />
files.<br />
Answer: You often get better compression results for a large number of smaller files<br />
by concatenating the uncompressed files and then compressing the result. That's<br />
why tar.gz is often superior to zip for large numbers of html files (like API docs).<br />
You will not get much better general-purpose compression than Zip, at least not until<br />
you have a specific class of data and know very much about its structure. Even then<br />
you'll need some experience and time working on a better compression method.<br />
You might want to take a look at this <strong>Java</strong> implementation of bzip2:<br />
http://www.aftexsw.com/aftex/products/java/bzip/<br />
It uses more CPU cycles and memory but typically compresses better<br />
than zip.<br />
--<br />
Marco<br />
Q: I need to programmatically replace an entry in a zip file.<br />
I could not quite get it using the ZipOutputStream because it simply creates a new<br />
file and write only that entry for me. The rest of the original entries are gone.<br />
Does anyone have a solution for this?<br />
Answer:<br />
Visit us here and you will find<br />
much more tips!<br />
1) Read the file (myfile.properties) out of the original Zip Archive (original.zip)<br />
2) Make your changes, write the file to the file system<br />
3) Create a New Archive (originalNew.zip)<br />
4) Write your edited file (myfile.properties) to originalNew.zip<br />
5) loop through all the entries in the original Zip archive (original.zip), adding them to<br />
the new archive (originalNew.zip) EXCEPT for the file you are replacing<br />
file:///F|/350_t/350_tips/general_java-IV.htm (1 of 10) [2002-02-27 21:18:34]