compression - BlackBerry - Problem with GZip decompression -


There is a strange problem that I'm running into, I can not work because it's described in the documentation. Br> If I'm using plain text file, then add GB to the resources of the Blackberry project and try to decompress it in the app, there will be unlimited loop, gzis.read () never return -1 ...

  Try {InputStream inputStream = getClass () GetResourceAsStream ("test.gz"); GZIP InputStream gzis = new GZIP InputStream (inputstream); Stringbuffer sb = new stringbuffer (); Four c; While ((C = (four) gzis.read ())! = -1) {sb.append (c); } String data = sb.toString (); Add (new RichTextField (data)); Gzis.close (); } Grip (IOException ioe) {}  

After compressed content, gzis.read () has a repetition of 65535. I've found that the only solution is dumb

  while ((c = (four) gzis.read ())! = -1 and c! = 65535)  

But I'm curious what's the reason, am I doing wrong, and why?

is an unsigned, 16-bit data type. Casting around -1 is 65535.

Change to:

  int i; While ((i = gzis.read ())! = -1) {sb.append ((four) i); }  

And it should work RIM's example of the API can not possibly work, because no four will ever be equal.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -