Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

path to load a file

 
vinitha simon
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a properties file inside the following folder structure

project\folder1\file.properties

I have to load this properties file from page1.java which is in the following folder structure....

project\folder2\sub_folder1\sub_fol2\sub_fol3\sub_fol4\sub_fol5\sub_fol6\page1.java

how do I do this ?
 
Harish Kashyap
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Properties properties = new Properties();
try {
properties.load(new FileInputStream("/project/folder1/file.properties"));
} catch (IOException e) {
}

you must use the absolute path or the relative path of the properties file.
remember, if you are executing p1.p2.A.class then your class could be in c:\p1\p2 folder, but you will be executing it from c:\ so the path of the properties file should be either absolute path or relative path to c:\
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic