Advertisement
Guest User

Untitled

a guest
Feb 17th, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public class TestKryoMain {
  2.  
  3. public static void main (String[] args) throws IOException {
  4. Log.DEBUG();
  5.  
  6. Kryo kryo = new Kryo();
  7. // Set serializer that can handle added & removed fields (but can't handle type change).
  8. kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
  9.  
  10. if (false) {
  11. Output output = new Output(new FileOutputStream("kryo.dat"));
  12. kryo.writeObject(output, new TestKryoData());
  13. output.close();
  14. } else {
  15. Input input = new Input(new FileInputStream("kryo.dat"));
  16. TestKryoData dataWrapper = kryo.readObject(input, TestKryoData.class);
  17. input.close();
  18.  
  19. System.out.println("ddd value should be 'ddd', got: " + dataWrapper.ddd);
  20. }
  21.  
  22. System.out.println("Done!");
  23. }
  24.  
  25. static public class TestKryoData {
  26. public String aaa = "aaa";
  27. // public String bbb = "bbb";
  28. public String ccc = "ccc";
  29. // public String ddd = bbb;
  30. public String ddd = "ddd";
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement