• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

zip decompression with j2me

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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� )
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Theres a utility Class from TinyLine

Look at this blog
http://javablogs.xyling.com/2005/04/gzip-library-for-j2me.html
 
Saloon Keeper
Posts: 28323
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
aruna gottimukkala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
A "dutch baby" is not a baby. But this tiny ad is baby sized:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic