Load properties file from external directory

I am currently loading properties files from a resource stream like this -

prop.load(LoadTest.class.getClassLoader().getResourceAsStream("database.properties"));

      

But what I'm looking for is if I can load properties files from any external directory. Suppose my file database.properties

is in

C:\logging-test\database.properties

Then how do I load the above properties file from that location? Any thoughts?

+3


source to share


1 answer


As @ madth3 pointed out, you can use another overload of the load () method on the Properties object to pass an InputStream referencing a file on the filesystem:



prop.load(new FileInputStream("C:\\logging-test\\database.properties"));

      

+6


source







All Articles