Skip to Content
avatar image
Former Member

File not found, Missing resource bundle

Hi

I have a problem in accessing files (XML and Resource bundles) in Java projects. I used to access these files in WD Java. The same piece of code does not work here.

e.g. When I create a new file object by providing the path name I get a file not found exception. The file exists in my package and I call it this way:

File f = new File("file.txt"); then in an input stream but it doesnt work. However in a J2EE project the same code works.

Similarly the resouce bundle never seems to work even if I give the fully classified class name for the property file. I can access property files in WD Java with ease. I understand that the root path changes and hence the problem. How should I solve it? Is there an elegant way which makes it work in all cases? Please throw some light on the root path for these projects. Thank you.

regards

LNV

Edited by: vln on Jan 16, 2008 9:34 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 19, 2008 at 09:28 PM

    You should be using

    <b>this.getClass().getResourceAsStream(filePath)</b>

    which will return you an InputStream.

    Check the JDK documentation for the respective methods in java.lang.Class and java.lang.ClassLoader.

    HTH!

    \-- Vladimir

    Add comment
    10|10000 characters needed characters exceeded