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


Java Output.toByteString方法代码示例

本文整理汇总了Java中com.google.protobuf.ByteString.Output.toByteString方法的典型用法代码示例。如果您正苦于以下问题:Java Output.toByteString方法的具体用法?Java Output.toByteString怎么用?Java Output.toByteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.ByteString.Output的用法示例。


在下文中一共展示了Output.toByteString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeMessageList

import com.google.protobuf.ByteString.Output; //导入方法依赖的package包/类
/**
 * Creates a {@link ByteString} by serializing the list of protos. Use
 * {@link #readMessageList(ByteString, Parser)} to deserialize.
 */
public static <T extends MessageLite> ByteString writeMessageList(List<T> protos) {
    Output output = ByteString.newOutput();
    try {
        writeMessageListTo(output, protos);
    } catch (IOException ex) {
        throw new IllegalStateException("Unable to write protobufs to memory");
    }

    return output.toByteString();
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:15,代码来源:ProtoListUtil.java

示例2: testNewOutput_Mutating

import com.google.protobuf.ByteString.Output; //导入方法依赖的package包/类
public void testNewOutput_Mutating() throws IOException {
  Output os = ByteString.newOutput(5);
  os.write(new byte[] {1, 2, 3, 4, 5});
  EvilOutputStream eos = new EvilOutputStream();
  os.writeTo(eos);
  byte[] capturedArray = eos.capturedArray;
  ByteString byteString = os.toByteString();
  byte[] oldValue = byteString.toByteArray();
  Arrays.fill(capturedArray, (byte) 0);
  byte[] newValue = byteString.toByteArray();
  assertTrue("Output must not provide access to the underlying byte array",
      Arrays.equals(oldValue, newValue));
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:14,代码来源:ByteStringTest.java

示例3: convertCredentialsToProto

import com.google.protobuf.ByteString.Output; //导入方法依赖的package包/类
public static ByteString convertCredentialsToProto(Credentials credentials) {
  if (credentials == null) {
    return null;
  }
  Output output = ByteString.newOutput();
  DataOutputStream dos = new DataOutputStream(output);
  try {
    credentials.writeTokenStorageToStream(dos);
    return output.toByteString();
  } catch (IOException e) {
    throw new TezUncheckedException("Failed to serialize Credentials", e);
  }
}
 
开发者ID:apache,项目名称:incubator-tez,代码行数:14,代码来源:DagTypeConverters.java


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