如何从黑莓应用程序中附加的zip文件检索数据? [英] How to retrieve data from a attached zip file in Blackberry application?
问题描述
我使用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.
推荐答案
使用两个压缩标准: GZip 和 ZLib 。
选择一个,然后压缩文件并添加到项目。
然后,您应该能够将其作为资源打开。
解压缩之后使用 GZIPInputStream 或 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.
示例(解压缩并打印从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屋!