Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

J2ME FileConnection  RSS feed

Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My program opens a file and reads it using the following code:

fc = (FileConnection);
fis = fc.openInputStream();
fdi = new DataInputStream(fis);

int inputChar2;
String strTar = new String();
while ( (inputChar2 = != -1) {

After the file is read, I store it in a String and open a second file, then I replace the previous String with the second file, and open a third file, etc. So, I keep updating a String with files that are all about 40 kilobytes. When I am trying to read the second file that I open (in the loop), I get an out of memory exception. How can I fix this? It doesn't make sense to me because I can always open the first file, no matter how big it is. But, after I store the first file into a String and then open and try to read the second file, I get the following exception. Please help! How can I fix this and why is it doing it?

at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+309)
at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
at com.sun.midp.lcdui.DefaultEventHandler$
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!