黑莓:阅读包装项目的文本文件(快) [英] Blackberry: Read a text file packaged in the project (faster)

查看:127
本文介绍了黑莓:阅读包装项目的文本文件(快)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这个方法:

<一个href=\"http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To_-_Add_plain_text_or_binary_files_to_an_application.html?nodeid=800687&vernum=0\" rel=\"nofollow\">http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To_-_Add_plain_text_or_binary_files_to_an_application.html?nodeid=800687&vernum=0

但它是稍微大的文本文件很慢。有谁知道的读取被包含在项目的纯文本文件更好的办法?有没有办法使用一个的FileConnection方式?

But it's REALLY slow for slightly large text files. Does anyone know of a better way of reading a plain text file that is included in the project? Is there a way to use FileConnection?

推荐答案

想通了使用信息的组合:

Figured it out using a combination of information:

IOUtilities.streamToBytes(是);

IOUtilities.streamToBytes(is);

直接在输入流。因此,一个更完整的例子如下:

Directly on the input stream. So a more complete example would be as follows:

班班组长=的Class.forName(com.packagename.stuff.FileDemo);

Class classs = Class.forName("com.packagename.stuff.FileDemo");

InputStream为= classs.getResourceAsStream(/测试);

InputStream is = classs.getResourceAsStream("/test");

字节[]数据= IOUtilities.streamToBytes(是);

byte[] data = IOUtilities.streamToBytes(is);

字符串结果=新的String(数据);

String result = new String(data);

新政?新政。

这篇关于黑莓:阅读包装项目的文本文件(快)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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