Absolute or Root Path for getClass().getResourceAsStream()

Hi everyone,

I'm somewhat of a Java Newbie and I have a Problem with concerning my properties file. My project is rather large and I'm using the following line for loading my properties file:

Properties prop = new Properties();

prop.load(getClass().getResourceAsStream("project.properties"));

Now if the prop-file is in the same folder as my java class it's working and this applies to relative paths. But with an absolute path it doesn't and I was wondering if any of you guys would have an idea how to adopt a absolute path or maybe some kind of class root path or you know another needo solution to my properties problem.

thanx in advance :)

& ciao 4 now

Julian

[732 byte] By [Julian_Tillmanna] at [2007-10-2 15:24:52]
# 1

The whole point of getResource is to avoid coding absolute paths. Resources live on the same directories, or in the same jar, as your class files.

If you want to read data from absolute paths that's fine (providing you're not in an Applet) but use FileInputStream, not getResoruceAsStream.

malcolmmca at 2007-7-13 14:39:19 > top of Java-index,Java Essentials,Java Programming...