Blackberry Development, java.lang.outofmemoryerror
Posted
by Nikesh Yadav
on Stack Overflow
See other posts from Stack Overflow
or by Nikesh Yadav
Published on 2010-06-09T07:21:06Z
Indexed on
2010/06/09
7:32 UTC
Read the original article
Hit count: 295
Hi Forum,
I am new to Blackberry development (I am using Eclipse with Blackberry plug-in), I am trying to read a text file, which I placed in the "src" folder of my Blackberry project and this text file just contain a word "Test". when I run the program, I gets "UncaughtException: java.lang.outofmemoryerror". Here is the code I am using, where "speech.txt" is the file I am trying to read and is placed in the "src" folder -
public class SpeechMain extends MainScreen {
public SpeechMain() {
try {
Class myClass = this.getClass();
InputStream is = null;
is = myClass.getResourceAsStream("speech.txt");
InputStreamReader isr = new InputStreamReader(is);
char c;
while ((c = (char)isr.read()) != -1) {
add(new LabelField("" + c));
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
add(new LabelField(e.getMessage()));
}
}
}
Thanks in advance.
Thanks, Nikesh
© Stack Overflow or respective owner