Skip to content

Instantly share code, notes, and snippets.

@matamehta
Forked from MichaelFichtner/HelloYaml.java
Created February 4, 2018 05:47
Show Gist options
  • Select an option

  • Save matamehta/a6a2defc9da0923989b46be92b3f4e2b to your computer and use it in GitHub Desktop.

Select an option

Save matamehta/a6a2defc9da0923989b46be92b3f4e2b to your computer and use it in GitHub Desktop.

Revisions

  1. @ericlee996 ericlee996 created this gist Sep 10, 2012.
    22 changes: 22 additions & 0 deletions HelloYaml.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    public class HelloYaml {
    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws FileNotFoundException {
    Yaml yaml = new Yaml();

    System.out.println(yaml.dump(yaml.load(new FileInputStream(new File(
    "hello_world.yaml")))));

    Map<String, Map<String, String>> values = (Map<String, Map<String, String>>) yaml
    .load(new FileInputStream(new File("hello_world.yaml")));

    for (String key : values.keySet()) {
    Map<String, String> subValues = values.get(key);
    System.out.println(key);

    for (String subValueKey : subValues.keySet()) {
    System.out.println(String.format("\t%s = %s",
    subValueKey, subValues.get(subValueKey)));
    }
    }
    }
    }