mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 10:19:51 +00:00
import MessagePack for Java implementation plan 1
This commit is contained in:
parent
c6a2569af8
commit
5393a0df16
5 changed files with 712 additions and 0 deletions
27
java-plan1/test.java
Normal file
27
java-plan1/test.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
class OpenByteArrayOutputStream extends ByteArrayOutputStream {
|
||||
int getCount() { return count; }
|
||||
byte[] getBuffer() { return buf; }
|
||||
}
|
||||
|
||||
public class test {
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
OpenByteArrayOutputStream out = new OpenByteArrayOutputStream();
|
||||
|
||||
Packer pk = new Packer(out);
|
||||
pk.packArray(3)
|
||||
.packInt(0)
|
||||
.packByte((byte)1)
|
||||
.packDouble(0.1);
|
||||
|
||||
Unpacker pac = new Unpacker();
|
||||
int nlen = pac.execute(out.getBuffer(), 0, out.getCount());
|
||||
if(pac.isFinished()) {
|
||||
System.out.println(pac.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue