In order to reach a configuration file contained in a jar file, you can use the following code snippet:
InputStream inputStream = getClass().getResourceAsStream("/config/config.properties");
Properties properties = new Properties();
properties.load(inputStream);
This code assumes that the configuration file is located in a folder named "config" at the root of your jar file. The getResourceAsStream method retrieves the file as an InputStream, which can be read using a Properties object to access individual properties.
Asked: 2023-05-15 06:20:13 +0000
Seen: 14 times
Last updated: May 15 '23