General Java Questions I
returns random cases in the range 0..2.
Answer: Don t assume that just because default is first in the code, that it will match
first. In fact the default is only used when there is no matching case, as you have
discovered.
>From the JLS(Java Language Specification):
If no case matches but there is a default label, then all statements after the matching
default label in the switch block, if any, are executed in sequence.
http://java.sun.com/docs/books/jls/html/14.doc.html#35518
  
gordon
 Q: I am looking for more efficient compression APIs esp. for *.doc and *.html files.
I need some Java APIs wherein I can implement various compression algorithms. I
have already the GZIP compression technique shipped with JDK s java.util.zip
package. I am looking for more efficient compression APIs esp. for *.doc and *.html
files.
Answer: You often get better compression results for a large number of smaller files
by concatenating the uncompressed files and then compressing the result. That s
why tar.gz is often superior to zip for large numbers of html files (like API docs).
You will not get much better general purpose compression than Zip, at least not until
you have a specific class of data and know very much about its structure. Even then
you ll need some experience and time working on a better compression method.
You might want to take a look at this Java implementation of bzip2:
http://www.aftexsw.com/aftex/products/java/bzip/
It uses more CPU cycles and memory but typically compresses better
than zip.
  
Marco
 Q: I need to programmatically replace an entry in a zip file.
I could not quite get it using the ZipOutputStream because it simply creates a new file
and write only that entry for me. The rest of the original entries are gone. 
Does anyone have a solution for this?
Answer:
1) Read the file (myfile.properties) out of the original Zip Archive (original.zip)
2) Make your changes, write the file to the file system
3) Create a New Archive (originalNew.zip)
4) Write your edited file (myfile.properties) to originalNew.zip
5) loop through all the entries in the original Zip archive (original.zip),  adding them to
the new archive (originalNew.zip) EXCEPT for the file you are replacing
(myfile.properties)
6) When you re done, erase the original and rename your new one to original.zip.
I believe that this may be the only way to do this, since there doesn t seem to be any
random access in the ZIP file. 
  
file:///F|/a_jsite/350_tips/general_java I.htm (24 of 33) [2001 07 08 11:24:51]






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java web hosting

 

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved