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 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
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: 10268
    
    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!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: access text file using relative path in J2me with Eclipse Pulsar