gaob13 / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Example of ObjectBuffer on front page does not correspond to the actual API #54

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
On the front page of Kryo (http://code.google.com/p/kryo/), in the usage 
examples, there is the following code.

ObjectBuffer buffer = new ObjectBuffer(kryo);
buffer.writeObject(someObject, new FileOutputStream("object.bin"));
someObject = buffer.readObject(new FileInputStream("object.bin"));
byte[] bytes = buffer.writeObject(someObject);
someObject = buffer.readObject(bytes);

However, in the documentation 
(http://kryo.googlecode.com/svn/api/com/esotericsoftware/kryo/ObjectBuffer.html)
, the signature for writeObject is given as writeObject(OutputStream output, 
Object object), the opposite of what is in the example. Furthermore, there does 
not seem to be a one parameter version of readObject anymore.

I believe the correct example would be:

ObjectBuffer buffer = new ObjectBuffer(kryo);
buffer.writeObject(new FileOutputStream("object.bin"), someObject);
someObject = buffer.readObject(new FileInputStream("object.bin"), 
someObject.getClass());
byte[] bytes = buffer.writeObject(someObject);
someObject = buffer.readObject(bytes);

Original issue reported on code.google.com by jeanfran...@gmail.com on 23 Mar 2012 at 4:04

GoogleCodeExporter commented 8 years ago
Thanks!

Original comment by nathan.s...@gmail.com on 29 Mar 2012 at 6:23