https://mkyong.com/java/java-properties-file-examples/
try (InputStream input = MainController.class.getClassLoader().getResourceAsStream("path.properties")) {
Properties prop = new Properties();
if (input == null) {
System.out.println("Sorry, unable to find config.properties");
return;
}
//load a properties file from class path, inside static method
prop.load(input);
//get the property value and print it out
System.out.println(prop.getProperty("db.url"));
System.out.println(prop.getProperty("db.user"));
System.out.println(prop.getProperty("db.password"));
} catch (IOException ex) {
ex.printStackTrace();
}
try (Reader input = new InputStreamReader( MainController.class.getClassLoader().getResourceAsStream("path.properties"), "UTF-8")) {
Properties prop = new Properties();
//load a properties file from class path, inside static method
prop.load(input);
//get the property value and print it out
System.out.println(prop.getProperty("srcMySQLPath"));
System.out.println(prop.getProperty("srcOraclePath"));
System.out.println(prop.getProperty("dstJoinedPath"));
// SET PATH TO STRING
srcMySQLPath = prop.getProperty("srcMySQLPath");
srcOraclePath = prop.getProperty("srcOraclePath");
dstJoinedPath = prop.getProperty("dstJoinedPath");
} catch (IOException ex) {
ex.printStackTrace();
}
try (Reader input = new InputStreamReader(new FileInputStream("C:\\path.properties"), "UTF-8")) {
Properties prop = new Properties();
//load a properties file from class path, inside static method
prop.load(input);
//get the property value and print it out
System.out.println(prop.getProperty("srcMySQLPath"));
System.out.println(prop.getProperty("srcOraclePath"));
System.out.println(prop.getProperty("dstJoinedPath"));
// SET PATH TO STRING
srcMySQLPath = prop.getProperty("srcMySQLPath");
srcOraclePath = prop.getProperty("srcOraclePath");
dstJoinedPath = prop.getProperty("dstJoinedPath");
} catch (IOException ex) {
System.out.println("PROPERTIES NOT LOADED");
ex.printStackTrace();
}