How can I access a property file called test.property in user.home?
This doesn’t work:
public class Properties {
private static java.util.Properties p = new java.util.Properties();
static {
try {
String home = System.getProperty("user.home");
home += "\\test.properties";
System.out.println("User home: " + home);
InputStream is = Properties.class.getResourceAsStream(home);
p.load(is);
} catch (FileNotFoundException e) {
System.out.println("property file could not be found!");
} catch (IOException e) {
e.printStackTrace();
}
}
}
You will probably find that the
user.homeis not on the run-time class-path of the application. In that case, use aFileinstead.