[英]Blackberry: Read a text file packaged in the project (faster)
I've tried this approach: 我尝试过这种方法:
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 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
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?
有没有办法使用FileConnection?
Figured it out using a combination of information: 使用以下信息组合出来:
IOUtilities.streamToBytes(is);
IOUtilities.streamToBytes(是);
Directly on the input stream. 直接在输入流上。 So a more complete example would be as follows:
所以一个更完整的例子如下:
Class classs = Class.forName("com.packagename.stuff.FileDemo");
Class classs = Class.forName(“com.packagename.stuff.FileDemo”);
InputStream is = classs.getResourceAsStream("/test");
InputStream是= classs.getResourceAsStream(“/ test”);
byte[] data = IOUtilities.streamToBytes(is);
byte [] data = IOUtilities.streamToBytes(is);
String result = new String(data);
String result = new String(data);
Deal? 交易吗? Deal.
应对。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.