This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes access text file using relative path in J2me with Eclipse Pulsar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "access text file using relative path in J2me with Eclipse Pulsar " Watch "access text file using relative path in J2me with Eclipse Pulsar " New topic
Author

access text file using relative path in J2me with Eclipse Pulsar

Jayesh Pokar
Greenhorn

Joined: Apr 26, 2011
Posts: 10
Hi,
I am beginner in j2me and I am trying to access one text file but was unable to do it.

I am trying to access in this way

InputStream is=this.getClass().getResourceAsStream("res/test.txt");

Eclipse Project Structure
MyApp
- src
- res
-test.txt

I saw build path and res folder is included.

Please tell me the solution......Thanks...



[Thumbnail for Untitled.png]

nishan satharasinghe
Greenhorn

Joined: Aug 27, 2008
Posts: 14
try without res/ part in the path
Jayesh Pokar
Greenhorn

Joined: Apr 26, 2011
Posts: 10
thanks Nishan for reply.....

I tried with /filename and it works fine.

By specifying path in this way is what we are telling start looking for file from root, am i right?

So it will first look into src folder and then to res folder and so on, wherever it finds the file it take that file.

I want to specify look only into res folder, and I am not able to do that.

I tried with...
res/filename
/res/filename
./res/filename

where I am wrong?

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Jayesh Pokar wrote:
I tried with /filename and it works fine....
I want to specify look only into res folder, and I am not able to do that.

I tried with...
res/filename
/res/filename
./res/filename


You already it correctly.
The res directory is designed for all your resources such as media and property files. Of course you can have nested directories such as res/properties or res/images etc


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
Consider Paul's rocket mass heater.
 
subject: access text file using relative path in J2me with Eclipse Pulsar
 
Similar Threads
How to read data from a text file
I/O operation in jsp
Reading from .txt file
Reading File from outside the WEBROOT
problem with Internet Explorer