Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Help needed to load relative path of file

703705Mar 7 2011 — edited Mar 7 2011
Hi,

I am new to java. I am trying to load a properties file from the root level of my project in workspace. I am using below code to get the relative path of my file

File appPath = new File(System.getProperty("user.dir"));
Properties props = new Properties();
props.load ( new FileInputStream ( new File (appPath +"/xyz.properties" )));

but this loads the current working directory of eclipse and not the path of my workspace where properties file is kept.I do not want to change the current working directory of eclipse physically as the project will be used on other systems as well. I just want to get it done thru coding. Can you please help me out.

Thanks in advance!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2011
Added on Mar 7 2011
7 comments
769 views