BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-01-2009, 07:42 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2009
Model: 8100
PIN: N/A
Carrier: vodafone
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Compress and Decompress using GZIP

Please Login to Remove!

Hi,
I want to compress and decompress data using gzip algorithm.

Please help,how do I achieve it?
Offline  
Old 06-01-2009, 09:55 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can use GZIPInputStream and GZIPOutputStream like you would other in/out streams to read and write.
Offline  
Old 06-02-2009, 02:49 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2009
Model: 8100
PIN: N/A
Carrier: vodafone
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Bemshaswing,
Thanks for the reply.
I have tried using GZIPInputStream and GZIPOutputStream.

It will be gr8 if someone provides me with sample code
Offline  
Old 06-02-2009, 09:17 AM   #4 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

here's an example of how it's done in standard java link

which doesn't differ greatly from gZip reading of inputStream
Code:
StringBuffer rawResponse = new StringBuffer();
InputStream inputStream = //some input stream
	GZIPInputStream gzipInputStream = new GZIPInputStream(inputStream);
				while (-1 != (length = gzipInputStream.read(responseData))) {
					rawResponse.append(new String(responseData, 0, length));
				
				}
Offline  
Old 06-04-2009, 05:37 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2009
Model: 8100
PIN: N/A
Carrier: vodafone
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Bemshaswing,
Thanks for the reply.
It worked for me.

Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.