Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read text file in memory card from MIDlet?

 
Bharathi Dhas Krishnasamy
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to read text file in memory card from MIDlet?
 
Gopinath Karyadath
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Bharathi Dhas Krishnasamy
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mr.Gobinath
 
Gopinath Karyadath
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are Welcome .. Happy Coding
 
Bharathi Dhas Krishnasamy
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gobinath actually I have to retrieve data from file in memory card and show in display.
Iā€™m still struggle with that.
I got a error in ā€œ FileConnection fileConnection = (FileConnection) Connector.open(file);ā€ line.
But I could get memory card path.
 
Swastik Dey
Rancher
Posts: 1639
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the error message? And what value are you getting in file variable?
 
Bharathi Dhas Krishnasamy
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey wrote:What is the error message? And what value are you getting in file variable?


MCTest.java



MCReadDemo.java


I got this output in my Mobile

Your file location:
file:///E:/download/MyFile.txt

Your file Data:
Your Data:

My Track:
1 2 3 5 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 9 11 14
 
Swastik Dey
Rancher
Posts: 1639
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You track counter never gets a value of 8, it means it is failing to satisfy

if (ch == 13) {

and the data is not getting appended to the vector.

So in addition to new line character, there might be carriage return character as well.

Instead of checking for one character, how about using readUTF()?
 
Bharathi Dhas Krishnasamy
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MCReadDemoMidlet


MCTest



I got this Exception


Starting emulator in execution mode
Installing suite from: http://127.0.0.1:1993/MCReadDemo-2.jad
java.lang.IllegalArgumentException
at javax.microedition.io.Connector.openPrim(), bci=51
at javax.microedition.io.Connector.open(), bci=3
at javax.microedition.io.Connector.open(), bci=3
at javax.microedition.io.Connector.open(), bci=2
at hello.MCTest.readfile(MCTest.java:31)
at hello.MCTest.<init>(MCTest.java:18)
at hello.MCReadDemoMidlet.<init>(MCReadDemoMidlet.java:17)
at java.lang.Class.newInstance(), bci=0
at com.sun.midp.main.CldcMIDletLoader.newInstance(), bci=46
at com.sun.midp.midlet.MIDletStateHandler.createMIDlet(), bci=66
at com.sun.midp.midlet.MIDletStateHandler.createAndRegisterMIDlet(), bci=17
at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=27
at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

Anyone can help?
 
Bharathi Dhas Krishnasamy
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still I didn't get solution....!

Ranch help me soon...!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic