Reputation: 468
propsdatabase = new Properties();
try
{
// load a properties file
InputStream dbin = getClass().getResourceAsStream("/database.properties");
//props.load(in);
propsdatabase.load(dbin);
}
catch (IOException ex)
{
ex.printStackTrace();
}
I Want to access a file which is out of the jar file. just in the location of the jar file.
I am using a properties file named database.properties in main/resources folder . The requirement is to change the location of database.properties outside the jar.
So I need something where the path can point to the location where the jar is .
I am using maven to build my jar
Upvotes: 0
Views: 442
Reputation: 6657
You can do it in two ways by defining absolute path for the pro
Class.getResourceAsStream ("/some/pkg/resource.properties");
And
ResourceBundle.getBundle ("some.pkg.resource");
Upvotes: 0
Reputation: 24630
FileInputStream dbin = new FileInputStream("/my/folder/database.properties");
Upvotes: 3