okio.ByteString.write()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中okio.ByteString.write()方法的一些代码示例,展示了ByteString.write()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString.write()方法的具体详情如下:
包路径:okio.ByteString
类名称:ByteString
方法名:write

ByteString.write介绍

[英]Writes the contents of this byte string to out.
[中]将此字节字符串的内容写入输出。

代码示例

代码示例来源:origin: spotify/apollo

private void sendReply(Response<ByteString> response) {
 if (!replied.compareAndSet(false, true)) {
  LOGGER.warn("Already replied to ongoing request {} - spurious response {}", request, response);
 } else {
  final HttpServletResponse httpResponse = (HttpServletResponse) asyncContext.getResponse();
  final StatusType status = response.status();
  httpResponse.setStatus(status.code(), status.reasonPhrase());
  response.headerEntries().forEach(entry ->
    httpResponse.addHeader(entry.getKey(), entry.getValue()));
  response.payload().ifPresent(payload -> {
   try {
    payload.write(httpResponse.getOutputStream());
   } catch (IOException e) {
    LOGGER.warn("Failed to write response", e);
   }
  });
  asyncContext.complete();
  logger.accept(this, Optional.of(response));
 }
}

代码示例来源:origin: square/okio

@Test public void write() throws Exception {
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 factory.decodeHex("616263").write(out);
 assertByteArraysEquals(new byte[] { 0x61, 0x62, 0x63 }, out.toByteArray());
}

代码示例来源:origin: huxq17/tractor

@Override public Buffer write(ByteString byteString) {
 if (byteString == null) throw new IllegalArgumentException("byteString == null");
 byteString.write(this);
 return this;
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void noneCryptoWrite() throws IOException {
 Crypto crypto = Crypto.none();
 ByteString foo = ByteString.encodeUtf8("foo");
 Buffer buffer = new Buffer();
 foo.write(crypto.encrypt(buffer.outputStream()));
 assertThat(buffer.readByteString()).isEqualTo(foo);
}

相关文章