read yml file properties using java

Viewed 37

I am trying to read YML file using java but not able to do. Object is null. I have refereed many examples but no luck . Little help will be appreciated.

ApplicationProperties contain pojo for yml file. My intention is to read values only.

InputStream inputStream = LoadExternalConfiguration.class.getClassLoader()
        .getResourceAsStream("application.yml");
Yaml yaml = new Yaml(new Constructor(ApplicationProperties.class));
HashMap yamlMap = yaml.load(inputStream);
System.out.println(yamlMap);
for (Object o : yamlMap.entrySet()) {
    System.out.println(o);
}

inputStream.close();

application.yml

dmsMapping:
  input_layer_name : "sign-values"
  output_Layer_volatile : "dms-range-v1"
  output_layer_IML : "dms-ts-mapped-data-iml"
0 Answers
Related