本文整理汇总了Java中com.google.protobuf.Message.writeDelimitedTo方法的典型用法代码示例。如果您正苦于以下问题:Java Message.writeDelimitedTo方法的具体用法?Java Message.writeDelimitedTo怎么用?Java Message.writeDelimitedTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.Message
的用法示例。
在下文中一共展示了Message.writeDelimitedTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import com.google.protobuf.Message; //导入方法依赖的package包/类
private static void send(final DataOutputStream out, final Op opcode,
final Message proto) throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Sending DataTransferOp " + proto.getClass().getSimpleName()
+ ": " + proto);
}
op(out, opcode);
proto.writeDelimitedTo(out);
out.flush();
}
示例2: toDelimitedByteArray
import com.google.protobuf.Message; //导入方法依赖的package包/类
/**
* @param m Message to get delimited pb serialization of (with pb magic prefix)
*/
public static byte [] toDelimitedByteArray(final Message m) throws IOException {
// Allocate arbitrary big size so we avoid resizing.
ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
baos.write(PB_MAGIC);
m.writeDelimitedTo(baos);
return baos.toByteArray();
}
示例3: write
import com.google.protobuf.Message; //导入方法依赖的package包/类
private static int write(final OutputStream dos, final Message header, final Message param,
final ByteBuffer cellBlock, final int totalSize)
throws IOException {
// I confirmed toBytes does same as DataOutputStream#writeInt.
dos.write(Bytes.toBytes(totalSize));
// This allocates a buffer that is the size of the message internally.
header.writeDelimitedTo(dos);
if (param != null) param.writeDelimitedTo(dos);
if (cellBlock != null) dos.write(cellBlock.array(), 0, cellBlock.remaining());
dos.flush();
return totalSize;
}