Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
greenback
Posts: 448
Registered: ‎10-17-2010

Loading .txt file into new screen

Does anyone know how to load the contents of a text file packaged locally with the app into a new screen?

 

My Flow:

 

1) List Items with titles

2) User clicks list item

3) Detect which item clicked

4) Based on click, load title, and content into a new screen

5) Go back to original screen (back key)

Also, is there sample code available for this? Seems simple enough. 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008

Re: Loading .txt file into new screen

You'll use Class.getResourceAsStream() to read the file from your jar.

 

See also Class.forName()

 

You get "Class" for your app name, then call getResourceAsStream().

 

Once you have the stream, you can read in the file contents as if it were a regular stream file.

 

Please use plain text.