Blackberry: read a text file packaged in a project (faster)

I 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

But it REALLY slows down for slightly larger text files. Does anyone know of a better way to read a simple text file that is included in a project? Is there a way to use FileConnection?

+3
source share
1 answer

Found this out using a combination of information:

IOUtilities.streamToBytes (is);

Directly on the input stream. Thus, a more complete example might be the following:

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

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

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

= String ();

Deal? Deal.

+5

Source: https://habr.com/ru/post/1755036/


All Articles