public void testSmallBuffers() throws Exception { ByteBuffer buf = ByteBuffer.allocate(1024); ByteBufferOutputStream byteBufferOutputStream = new ByteBufferOutputStream(buf); Output testOutput = new Output(byteBufferOutputStream); testOutput.writeBytes(new byte[512]); testOutput.writeBytes(new byte[512]); testOutput.flush(); ByteBufferInputStream testInputs = new ByteBufferInputStream(); buf.flip(); testInputs.setByteBuffer(buf); Input input = new Input(testInputs, 512); byte[] toRead = new byte[512]; input.readBytes(toRead); input.readBytes(toRead); }
public String serialize(JScene sceneToSerialize) { Output output = new Output(new ByteBufferOutputStream()); kryo.writeObject(output, sceneToSerialize); return packToString(output); }