# HG changeset patch # User one # Date 1381574575 -32400 # Node ID 98144dbff4100dd7f295266bc94e4d5a4573f724 # Parent b82cdd44b1c1ede237b4f2d578320edea62e08ea Added WriteHardDisk.java : Msgpack practice diff -r b82cdd44b1c1 -r 98144dbff410 .classpath --- a/.classpath Mon Jun 10 00:21:06 2013 +0900 +++ b/.classpath Sat Oct 12 19:42:55 2013 +0900 @@ -7,5 +7,6 @@ + diff -r b82cdd44b1c1 -r 98144dbff410 src/ie/oshiro/messagepack/io/WriteHardDisk.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ie/oshiro/messagepack/io/WriteHardDisk.java Sat Oct 12 19:42:55 2013 +0900 @@ -0,0 +1,39 @@ +package ie.oshiro.messagepack.io; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.msgpack.MessagePack; +import org.msgpack.annotation.Message; +import org.msgpack.type.Value; + +public class WriteHardDisk { + + public static void main(String[] args) throws IOException { + MessagePack msgpack = new MessagePack(); + ClassA c = new ClassA(); + Value v = msgpack.unconvert(c); + ClassA convertedC = msgpack.convert(v, ClassA.class); + + File file = new File("./tmp/WriteHardDiskOut"); + FileOutputStream out = new FileOutputStream(file); + msgpack.write(out, v); + out.flush(); + FileInputStream in = new FileInputStream(file); + Value v2 = msgpack.read(in); + ClassA convertedC2 = msgpack.convert(v2, ClassA.class); + System.out.println(convertedC.getNum() == convertedC2.getNum()); + } + + @Message + public static class ClassA { + int num; + public ClassA() { num = 0; } + public ClassA(int _num) { num = _num; } + public void setNum(int _num) { num = _num; } + public int getNum() { return num; } + } + +} diff -r b82cdd44b1c1 -r 98144dbff410 src/ie/oshiro/messagepack/practice/MSGFJListTest.java --- a/src/ie/oshiro/messagepack/practice/MSGFJListTest.java Mon Jun 10 00:21:06 2013 +0900 +++ b/src/ie/oshiro/messagepack/practice/MSGFJListTest.java Sat Oct 12 19:42:55 2013 +0900 @@ -24,6 +24,7 @@ for(Value v: (List) msgpack.read(bytes, List.class)) { System.out.println(v.asIntegerValue()); } + System.out.println(writeList); /* // Cannot find template for class fj.data.List class Value v = msgpack.unconvert(writeList);