import com.esotericsoftware.yamlbeans.YamlReader; public class Person { private String name; private int age; // Getters and setters public static void main(String[] args) throws Exception { YamlReader reader = new YamlReader(new FileReader("person.yaml")); Person person = reader.read(Person.class); } } import com.esotericsoftware.yamlbeans.YamlReader; import java.util.List; public class Books { private List<String> titles; // Getter and setter public static void main(String[] args) throws Exception { YamlReader reader = new YamlReader(new FileReader("books.yaml")); Books books = reader.read(Books.class); List<String> titles = books.getTitles(); for (String title : titles) { System.out.println(title); } } }


上一篇:
下一篇:
切换中文