@Test public void getYmlByFileNamePerfect() throws FileNotFoundException { List<LinkedHashMap<String, String>> mapList = yamlUtil.getYmlByFileNamePerfect("E:/1.yaml"); for (LinkedHashMap<String, String> map:mapList) { Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator(); while(iterator.hasNext()) { Map.Entry<String, String> next = iterator.next(); System.out.println(next.getKey()+"================="+next.getValue()); } System.out.println(); System.out.println(); System.out.println(); System.out.println(); System.out.println(); } }
public static List<LinkedHashMap<String, String>> getYmlByFileNamePerfect(String filename) throws FileNotFoundException { resultArray = new ArrayList<>(); if (filename == null) { filename = YAMLFILE; } File file = new File(filename); FileInputStream fis = new FileInputStream(file); Yaml yaml = new Yaml(); Iterable<Object> ret = yaml.loadAll(fis); for (Object o:ret) { result = new LinkedHashMap<String, String>(); Map<String, Object> param = (Map<String, Object>) o; for (Map.Entry<String, Object> entry:param.entrySet()) { String key = entry.getKey(); Object val = entry.getValue(); if (val instanceof Map) { forEachYaml(key, (Map<String, Object>) val); } else { result.put(key, val.toString()); } } resultArray.add(result); } return resultArray; }
YamlUtil { public static List<LinkedHashMap<String, String>> getYmlByFileNamePerfect(String filename) throws FileNotFoundException { resultArray = new ArrayList<>(); if (filename == null) { filename = YAMLFILE; } File file = new File(filename); FileInputStream fis = new FileInputStream(file); Yaml yaml = new Yaml(); Iterable<Object> ret = yaml.loadAll(fis); for (Object o:ret) { result = new LinkedHashMap<String, String>(); Map<String, Object> param = (Map<String, Object>) o; for (Map.Entry<String, Object> entry:param.entrySet()) { String key = entry.getKey(); Object val = entry.getValue(); if (val instanceof Map) { forEachYaml(key, (Map<String, Object>) val); } else { result.put(key, val.toString()); } } resultArray.add(result); } return resultArray; } }
YamlUtil { public static List<LinkedHashMap<String, String>> getYmlByFileNamePerfect(String filename) throws FileNotFoundException { resultArray = new ArrayList<>(); if (filename == null) { filename = YAMLFILE; } File file = new File(filename); FileInputStream fis = new FileInputStream(file); Yaml yaml = new Yaml(); Iterable<Object> ret = yaml.loadAll(fis); for (Object o:ret) { result = new LinkedHashMap<String, String>(); Map<String, Object> param = (Map<String, Object>) o; for (Map.Entry<String, Object> entry:param.entrySet()) { String key = entry.getKey(); Object val = entry.getValue(); if (val instanceof Map) { forEachYaml(key, (Map<String, Object>) val); } else { result.put(key, val.toString()); } } resultArray.add(result); } return resultArray; }  }
YamlUtil { public static List<LinkedHashMap<String, String>> getYmlByFileNamePerfect(String filename) throws FileNotFoundException { resultArray = new ArrayList<>(); if (filename == null) { filename = YAMLFILE; } File file = new File(filename); FileInputStream fis = new FileInputStream(file); Yaml yaml = new Yaml(); Iterable<Object> ret = yaml.loadAll(fis); for (Object o:ret) { result = new LinkedHashMap<String, String>(); Map<String, Object> param = (Map<String, Object>) o; for (Map.Entry<String, Object> entry:param.entrySet()) { String key = entry.getKey(); Object val = entry.getValue(); if (val instanceof Map) { forEachYaml(key, (Map<String, Object>) val); } else { result.put(key, val.toString()); } } resultArray.add(result); } return resultArray; }  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); }
YamlUtil { public static List<LinkedHashMap<String, String>> getYmlByFileNamePerfect(String filename) throws FileNotFoundException { resultArray = new ArrayList<>(); if (filename == null) { filename = YAMLFILE; } File file = new File(filename); FileInputStream fis = new FileInputStream(file); Yaml yaml = new Yaml(); Iterable<Object> ret = yaml.loadAll(fis); for (Object o:ret) { result = new LinkedHashMap<String, String>(); Map<String, Object> param = (Map<String, Object>) o; for (Map.Entry<String, Object> entry:param.entrySet()) { String key = entry.getKey(); Object val = entry.getValue(); if (val instanceof Map) { forEachYaml(key, (Map<String, Object>) val); } else { result.put(key, val.toString()); } } resultArray.add(result); } return resultArray; }  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);  }