开发者

Blackberry - Programmatically extract/open zip file

开发者 https://www.devze.com 2022-12-09 21:46 出处:网络
I have looked online with mixed results, but is there a way to programmatically extract a zip file on the BB? Very basic my app will display different encrypted file types, and those files are deliver

I have looked online with mixed results, but is there a way to programmatically extract a zip file on the BB? Very basic my app will display different encrypted file types, and those files are delivered in a zip file. My idea was to 开发者_Go百科have the user browse to the file on their SDCard, select it, and I extract what i need as a stream from the file. is this possible?


Use GZIPInputStream

Example:

    try
    {
        InputStream inputStream = httpConnection.openInputStream();
        GZIPInputStream gzis = new GZIPInputStream(inputStream);
        StringBuffer sb = new StringBuffer();

        char c;
        while ((c = (char)gzis.read()) != -1)
        {
            sb.append(c);
        }

        String data = sb.toString();

        gzis.close();
    }
    catch(IOException ioe)
    {
    }


Just two things:

  • In BB API there are only GZip and ZLib support, and no multiple files compression support, so it's not possible to compress several files and extract only one of them.
  • Up to my experience, such functionality will fly on simulator, but may be really performance-killing on real device

See How to retrieve data from a attached zip file in Blackberry application?

PS Actually you can implement custom multi-entries stream and parse it after decompress, but that seems to be useless, if you want this archive format to be supported in other applications.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号