### Question:
YamlUtil { public static StringWriter dumpAll(List list) { Yaml yaml = new Yaml(); StringWriter stringWriter = new StringWriter(); yaml.dumpAll(list.iterator(), stringWriter); return stringWriter; }  final static String key(String key); static List<LinkedHashMap<String, String>> getYmlByFileNamePerfect(String filename); static LinkedHashMap<String, String> getYmlByFileName(String filename); static Map<String, String> forEachYaml(String key_str, Map<String, Object> obj); static String getValue(String filename, String key); static StringWriter dump(Object obj); static StringWriter dumpAll(List list);  }### Answer:
@Test public void dumpAll() throws IOException { Address adr1 = new Address(); adr1.setCity("Royal Oak"); adr1.setLines("458 Walkman"); adr1.setPostal("48046"); adr1.setState("MI"); Address adr2 = new Address(); adr2.setCity("Royal Oak"); adr2.setLines("458 Walkman"); adr2.setPostal("48046"); adr2.setState("MI"); List<Address> list = new ArrayList<>(); list.add(adr1); list.add(adr2); Map<String, Object> data = new HashMap<>(); data.put("name", "Silenthand Olleander".trim()); data.put("race", "Human".trim()); data.put("chinese", "哈哈".trim()); Representer representer = new Representer(); representer.addClassTag(Address.class, Tag.MAP); representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); representer.setDefaultScalarStyle(DumperOptions.ScalarStyle.FOLDED); DumperOptions optionsNormal = new DumperOptions(); optionsNormal.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW); DumperOptions optionsPretty = new DumperOptions(); optionsPretty.setIndent(2); optionsPretty.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); optionsPretty.setPrettyFlow(true); optionsPretty.setDefaultScalarStyle(DumperOptions.ScalarStyle.FOLDED); optionsPretty.setAllowUnicode(true); optionsPretty.setSplitLines(false); Yaml yaml = new Yaml(representer, optionsPretty); FileWriter fw = new FileWriter("E:\\1.yaml"); yaml.dumpAll(list.iterator(), fw); yaml.dump(data, fw); StringWriter stringWriter = new StringWriter(); yaml.dumpAll(list.iterator(), stringWriter); System.out.println(stringWriter.toString()); }