如何检索从黑莓应用程序附带的zip文件中的数据? [英] How to retrieve data from a attached zip file in Blackberry application?

查看:107
本文介绍了如何检索从黑莓应用程序附带的zip文件中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Eclipse来为黑莓打造的应用程序。我连着一个zip文件与我的应用程序。请帮帮我,我不知道如何检索数据形成应用开发的zip文件。

I am using eclipse to build application for Blackberry. I attached a zip file with my application. Please help me, I don't know how to retrieve data form the zip file in application development.

推荐答案

在黑莓手机,我们可以用两个COM pression标尺 - 的的GZip 的ZLib
选择一个,那么COM preSS您的文件,并添加到项目。
然后,你应该能够打开它作为一种资源。
与<一个是DECOM preSS后href=\"http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/com$p$pss/GZIPInputStream.html\"相对=nofollow> GZIPInputStream 或<一个href=\"http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/com$p$pss/ZLibInputStream.html\"相对=nofollow> ZLibInputStream 相应。

In BlackBerry we can use two compression standarts: GZip and ZLib. Choose one, then compress your file and add to project. Then you should be able to open it as an resource. After that decompress it with GZIPInputStream or ZLibInputStream accordingly.

示例(uncom preSS和test.gz连接到投影打印文本):

Example (uncompress and print text from test.gz attached to project):

try
{
    InputStream inputStream = getClass().getResourceAsStream("test.gz");
    GZIPInputStream gzis = new GZIPInputStream(inputStream);
    StringBuffer sb = new StringBuffer();

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

    String data = sb.toString();
    add(new RichTextField(data));
    gzis.close();
}
catch(IOException ioe)
{
    //do something here
}

这篇关于如何检索从黑莓应用程序附带的zip文件中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆