Home arrow static arrow Java Programming [Archive] - What api would I use to see if a file is compressed
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - What api would I use to see if a file is compressed
This topic has 4 replies on 1 page.

Posts:31
Registered: 6/21/04
What api would I use to see if a file is compressed  
Jun 21, 2004 10:33 AM



 
Please post leave a sample of code if you have any.
 

Posts:50
Registered: 12/9/97
Re: What api would I use to see if a file is compressed  
Jun 21, 2004 10:39 AM (reply 1 of 4)



 
What kind of compression are you expecting? zip, lzw, mpeg, mp3....??? Once you can answer that question, you can probably find the appropriate API's to use to determine whether or not a file is compressed according to whichever algorithms you are expecting.

Cheers,
Alexandra
 

Posts:31
Registered: 6/21/04
Re: What api would I use to see if a file is compressed  
Jun 21, 2004 10:40 AM (reply 2 of 4)



 
Zip
 

Posts:31,095
Registered: 4/30/99
Re: What api would I use to see if a file is compressed  
Jun 21, 2004 10:50 AM (reply 3 of 4)



 
A zip archive is supposed to satisfy a specification that takes several pages to write down. There's no magic wand that answers your question. So don't ask it. You are better off to assume that your input is a zip archive, and just start processing it. If it doesn't satisfy the specification, eventually your program will crash. At that point you flame the person who provided you with the faulty zip file and get them to send you a proper file.

PC²
 

Posts:50
Registered: 12/9/97
Re: What api would I use to see if a file is compressed  
Jun 21, 2004 11:00 AM (reply 4 of 4)



 
Use this API:
http://java.sun.com/j2se/1.4.2/docs/api/index.html

If it isn't a ZIP file your code should catch the ZipException to determine when the file is noncompliant.

Cheers,
Alexandra
 
This topic has 4 replies on 1 page.