本文整理匯總了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;
}