本文整理了Java中okio.ByteString.write()
方法的一些代码示例,展示了ByteString.write()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString.write()
方法的具体详情如下:
包路径:okio.ByteString
类名称: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);
}
内容来源于网络,如有侵权,请联系作者删除!