Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Reading using J2ME

 
Bhanu Peruvemba
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to read a .wav/.txt file in J2ME using the following code

InputConnection connStream = (InputConnection) Connector.open( "file:///C:/abc.txt", Connector.READ );

and I get a ConnectionNotFoundException. I would like to know where should I be storing the abc.txt file. Could I store it in any directory on my C:\ drive or should I put it in a particular directory. I am using Eclipse and Sun's WTK.

Does Sun's WTK support file protocol.


Thanks in advance
bhanu
 
Aryan Khan
Ranch Hand
Posts: 290
Java Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Which version of the WTK are u using...It must be 2.2 to support FileConnection.
Also you will get a FileConnection from the scheme "file://".

HTH
Ahmad Khan
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
InputStreamReader isr = new InputStreamReader(this.getClass().getResourceAsStream(/a.txt));

put your a.txt in your res directory.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!