I test SnakeYAML library to read .yaml documents. I have read Example 2.27. Invoice from and I get object:
Yaml yaml = new Yaml();
Object o = yaml.load(content);
where content is String loaded from file using Files.readAllBytes, encoding.decode (encoding is StandardCharsets.UTF_8)
Reflection gaves me that o is type of java.util.LinkedHashMap and I can iterate over them:
Set entrySet = o.entrySet();
Iterator it = entrySet.iterator();
System.out.println("LinkedHashMap entries : ");
Object entry = it.next();
Reflection return that type of entry is LinkedHashMap$Entry. But is **problem**: internal class LinkedHashMap$Entry is private and I can't declare objects this type.
How I can get pair from entry, iterator or entrSet? Use the public interface instead.
以上就是How I can get key, value pair from LinkedHashMap iterator?的详细内容，更多请关注web前端其它相关文章！