当前位置: 首页>>代码示例>>Java>>正文


Java UnsafeOutput.flush方法代码示例

本文整理汇总了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());
}
 
开发者ID:esialb,项目名称:kryo-mavenized,代码行数:20,代码来源:UnsafeInputOutputTest.java

示例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());
}
 
开发者ID:esialb,项目名称:kryo-mavenized,代码行数:17,代码来源:UnsafeInputOutputTest.java

示例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();
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:8,代码来源:SerializerTester.java

示例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());
}
 
开发者ID:esialb,项目名称:kryo-mavenized,代码行数:16,代码来源:UnsafeInputOutputTest.java


注:本文中的com.esotericsoftware.kryo.io.UnsafeOutput.flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。