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 ]