I have placed a properties file in below location. i created a folder in root and placed a properties file there.
/someFolder/some.properties
Now through java i need read properties using Properties class. can i give path as below?
Properties props = new Properties();
props.load(new FileInputStream("/someFolder/some.properties")); OR
props.load(new FileInputStream(“/someFolder//some.properties”));
Thanks!
Yes, you can give the path as in the first example and the second example will also work though there is no requirement for the
//. You may has seen paths using\\, as the\character requires escaping in string literals but the/does not require escaping.Instead of hard-coding the path into the code, consider specifying the path via a property (or some other configuration setting):
Then access the path via
System.getProperty("my.property.file");.