File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes How to read text file in memory card from MIDlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "How to read text file in memory card from MIDlet?" Watch "How to read text file in memory card from MIDlet?" New topic
Author

How to read text file in memory card from MIDlet?

Bharathi Dhas Krishnasamy
Greenhorn

Joined: Jun 20, 2009
Posts: 26
How to read text file in memory card from MIDlet?


Bharathi Dhas.K
Gopinath Karyadath
Ranch Hand

Joined: Oct 14, 2009
Posts: 87
Bharathi Dhas Krishnasamy
Greenhorn

Joined: Jun 20, 2009
Posts: 26
Thank you Mr.Gobinath
Gopinath Karyadath
Ranch Hand

Joined: Oct 14, 2009
Posts: 87
You are Welcome .. Happy Coding
Bharathi Dhas Krishnasamy
Greenhorn

Joined: Jun 20, 2009
Posts: 26
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

Joined: Jan 08, 2009
Posts: 1479
    
    6

What is the error message? And what value are you getting in file variable?


Swastik
Bharathi Dhas Krishnasamy
Greenhorn

Joined: Jun 20, 2009
Posts: 26
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

Joined: Jan 08, 2009
Posts: 1479
    
    6

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

Joined: Jun 20, 2009
Posts: 26
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?
yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
visit these sites. You may get answers here.

http://discussion.forum.nokia.com/forum/showthread.php?57674-is-there-a-File-class-equivalent-in-J2ME

http://www.forum.nokia.com/info/sw.nokia.com/id/82644083-2f4b-4775-a292-c02d6bf5be57/Introduction_To_The_FileConnection_API_v1_1.zip.html

http://www.velocityreviews.com/forums/t236775-using-files-in-j2me.
Bharathi Dhas Krishnasamy
Greenhorn

Joined: Jun 20, 2009
Posts: 26
Still I didn't get solution....!

Ranch help me soon...!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to read text file in memory card from MIDlet?