Is there an equivalent Builder object for Java?
This code is meant for C#. Does anyone know where the source code is so I can build a Java version of this?
var configBuilder = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddJsonFile("secret.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
Would be easier if there was such a think so I don't need to do this:
protected String readPropertyFromLocalConfig(String propertyName) {
try (FileInputStream fis = new FileInputStream("local.settings.json)) {
String data = IOUtils.toString(fis, ENCODING);
try {
JSONObject jsonObject = new JSONObject(data);
return (String)((JSONObject)jsonObject.get("Values")).get(propertyName);
} catch (JSONException err){
log.error("Error reading file", err.toString());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return StringUtil.EMPTY_STRING;
}