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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-15 06:20:13 +0000
Seen: 14 times
Last updated: May 15 '23
How can I insert a Cookie in the Nginx Configuration File?
What could be the reason for the node app not functioning on Namecheap hosting?
How can I relocate the node_modules directory from within the Angular project?
In what way can I transition from Traefik 2.4.2 to the latest version 2.9.x?
I encountered an error while attempting to install ingress-nginix using the YAML manifest.