Skip to content

Instantly share code, notes, and snippets.

@binfeng
Forked from ericlee996/HelloYaml.java
Created January 19, 2014 21:55
Show Gist options
  • Save binfeng/8511482 to your computer and use it in GitHub Desktop.
Save binfeng/8511482 to your computer and use it in GitHub Desktop.
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)));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment