aspose file tools*
The moose likes Java Micro Edition and the fly likes zip decompression with j2me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "zip decompression with j2me " Watch "zip decompression with j2me " New topic
Author

zip decompression with j2me

aruna gottimukkala
Greenhorn

Joined: Dec 20, 2007
Posts: 2
Hi,

I am a new to J2ME. I am trying develop application to download a zip file from our server and decompress it in a location on Pocket PC, PDA and mobiles.
Could anyone please give me some ideas or refer me to some web sites where I can found some relevant information

Thanks,
Aruna.G
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
The standard development kits will have a java class that is used for zip inflate./deflate - the format is apparently very similar to the dot jar ( java archive ) file format which is similar to war - web arcive.

All of these use Lempel-Ziv-Welch (LZW)
Lempel-Ziv-Welch (LZW) is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch. It was published by Welch in 1984 as an improved implementation of the LZ78 algorithm published by Lempel and Ziv in 1978. The algorithm is designed to be fast to implement but is not usually optimal because it performs only limited analysis of the data.


( cite from Wikipedia� )


"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Syam Sathyan George
Ranch Hand

Joined: Apr 26, 2006
Posts: 64
Theres a utility Class from TinyLine

Look at this blog
http://javablogs.xyling.com/2005/04/gzip-library-for-j2me.html


Syam.Sathyan.George
(My boss is a Jewish carpenter)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

A JAR file is simply a ZIP file with a manifest in it. The standard Java classes provide functions to browse and unzip ZIP and JAR archives as well as to create (but not update) them. They're a little confusing, but not too much so.

If your mobile JRE supports the java.util.zip classes, I recommend using them.


Customer surveys are for companies who didn't pay proper attention to begin with.
aruna gottimukkala
Greenhorn

Joined: Dec 20, 2007
Posts: 2
Hi All,

Thank you very much for your replies. I cannot use java.util.zip package since the PDA I am targeting supports only the CLDC profile in J2ME(which dont have the java.util.zip pckage in its JSRs). I selected the java4ever gzip utility I have mainly two problems:

1) Can I use that gzip utility to decompress zip files or I have to use that utility for reference only.
2) I started downloading the zip file with the j2me HttpConnection and its always giving me 401 response code. I could not understand Where I am wrong, I thought its the authentication problem and encoded the username and password but still no use. Could any one please tell me why I am getting this 401 response code.

Here is my code which gets the data from server:

private String url = "http://mobile.doxtop.com/z/ec284451.zip";
HttpConnection c = null;
InputStream is = null;
OutputStream os = null;

try
{
c = (HttpConnection)Connector.open(url,Connector.READ,true);
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty("Content-Type", "*/*" );
c.setRequestProperty("Accept", "*/*");
c.setRequestProperty("IF-Modified-Since", "10 Nov 2000 17:29:12 GMT");
c.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
c.setRequestProperty("Content-Language", "en-US");

byte[] bytes_encode;
String s = encode("qa"+":"+"qa1");

System.out.println("ZipDownload.downloadZip(): Encoded Bytes"+ s );
c.setRequestProperty("Authorization", "Basic " + s);

int status = c.getResponseCode();
if (status != HttpConnection.HTTP_OK)
{
throw new IOException("Server response not OK " +c.getResponseCode());
}
else
{
DataInputStream dis = new DataInputStream ( c.openInputStream ( ) ) ;
dis.readFully ( bytes ) ;
byte[] decompressed = GZIP.inflate(bytes);
}
catch (Exception e)
{
Alert myAlert= new Alert("Server response not OK "+ c.getResponseCode());

myAlert.setTimeout(Alert.FOREVER);
e.printStackTrace();
}

Thanks
Aruna.G
[ January 02, 2008: Message edited by: aruna gottimukkala ]
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Originally posted by Tim Holloway:
If your mobile JRE supports the java.util.zip classes, I recommend using them.


Poster states a remarkably limitied api, which I did not really believe and formatted all the supplied code in the editor and went to find the compression utility and got the DUH of the DAY award:

Connected Limited Device Configuration Technology API Documentation

I looked at the overview pages and it states the cldc runs at a lower layer than what I expected ( a UML sort of explaination of where it fits in ) but one would expect a compression algorithm to be avalable in the api for a limited capabilities device: It is for the device I have an api for.

Many compression algorithms are well studied in open literature and I suggest the poster attempt to read and study them. The only alternative I see is to use a library by some vendor, but such lib does not provide the poster any true avenue of exploration of failure modes of such lib - and on that basis alone I suggest study of LZW compression algorithm because of personal experience and that's just my nature.

DIY ( google it folks )
[ January 07, 2008: Message edited by: Nicholas Jordan ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: zip decompression with j2me