import io.protostuff.runtime.RuntimeSchema; import io.protostuff.YamlIOUtil; import java.io.ByteArrayOutputStream; import java.io.IOException; public class ProtostuffYamlExample { public static void main(String[] args) throws IOException { User user = new User("John", 30); RuntimeSchema<User> schema = RuntimeSchema.createFrom(User.class); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); YamlIOUtil.writeTo(outputStream, user, schema, false); String yamlData = outputStream.toString(); System.out.println(yamlData); } } public class User { private String name; private int age; public User(String name, int age) { this.name = name; this.age = age; } }


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