本文整理汇总了Java中com.esotericsoftware.kryo.io.UnsafeOutput.flush方法的典型用法代码示例。如果您正苦于以下问题:Java UnsafeOutput.flush方法的具体用法?Java UnsafeOutput.flush怎么用?Java UnsafeOutput.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esotericsoftware.kryo.io.UnsafeOutput
的用法示例。
在下文中一共展示了UnsafeOutput.flush方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWriteBytes
import com.esotericsoftware.kryo.io.UnsafeOutput; //导入方法依赖的package包/类
public void testWriteBytes () throws IOException {
UnsafeOutput buffer = new UnsafeOutput(512);
buffer.writeBytes(new byte[] {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26});
buffer.writeBytes(new byte[] {31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46});
buffer.writeByte(51);
buffer.writeBytes(new byte[] {52, 53, 54, 55, 56, 57, 58});
buffer.writeByte(61);
buffer.writeByte(62);
buffer.writeByte(63);
buffer.writeByte(64);
buffer.writeByte(65);
buffer.flush();
assertEquals(new byte[] { //
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, //
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, //
51, 52, 53, 54, 55, 56, 57, 58, //
61, 62, 63, 64, 65}, buffer.toBytes());
}
示例2: runVarIntTest
import com.esotericsoftware.kryo.io.UnsafeOutput; //导入方法依赖的package包/类
private void runVarIntTest (UnsafeOutput write, ByteArrayOutputStream os) throws IOException {
write.writeVarInt(0, true);
write.writeVarInt(63, true);
write.writeVarInt(64, true);
write.writeVarInt(65535, true);
assertEquals(6, write.total());
write.flush();
assertEquals(6, os.size());
Input read = new UnsafeInput(os.toByteArray());
assertEquals(0, read.readVarInt(true));
assertEquals(63, read.readVarInt(true));
assertEquals(64, read.readVarInt(true));
assertEquals(65535, read.readVarInt(true));
assertEquals(true, read.eof());
}
示例3: toBytes
import com.esotericsoftware.kryo.io.UnsafeOutput; //导入方法依赖的package包/类
private byte[] toBytes(SubjectT subject) {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
UnsafeOutput out = new UnsafeOutput(byteOut);
kryo.writeObject(out, subject);
out.flush();
return byteOut.toByteArray();
}
示例4: testOutputStream
import com.esotericsoftware.kryo.io.UnsafeOutput; //导入方法依赖的package包/类
public void testOutputStream () throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
UnsafeOutput output = new UnsafeOutput(buffer, 2);
output.writeBytes(new byte[] {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26});
output.writeBytes(new byte[] {31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46});
output.writeBytes(new byte[] {51, 52, 53, 54, 55, 56, 57, 58});
output.writeBytes(new byte[] {61, 62, 63, 64, 65});
output.flush();
assertEquals(new byte[] { //
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, //
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, //
51, 52, 53, 54, 55, 56, 57, 58, //
61, 62, 63, 64, 65}, buffer.toByteArray());
}