okio.Buffer.writeTo()方法的使用及代码示例

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

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

Buffer.writeTo介绍

[英]Write the contents of this to out.
[中]把这篇文章的内容写出来。

代码示例

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

@Test public void writeToStream() throws Exception {
 Buffer buffer = new Buffer().writeUtf8("hello, world!");
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 buffer.writeTo(out);
 String outString = new String(out.toByteArray(), UTF_8);
 assertEquals("hello, world!", outString);
 assertEquals(0, buffer.size());
}

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

@Test public void writeToSpanningSegments() throws Exception {
 Buffer buffer = new Buffer();
 buffer.writeUtf8(repeat('a', SEGMENT_SIZE * 2));
 buffer.writeUtf8(repeat('b', SEGMENT_SIZE * 2));
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 buffer.skip(10);
 buffer.writeTo(out, SEGMENT_SIZE * 3);
 assertEquals(repeat('a', SEGMENT_SIZE * 2 - 10) + repeat('b', SEGMENT_SIZE + 10),
   out.toString());
 assertEquals(repeat('b', SEGMENT_SIZE - 10), buffer.readUtf8(buffer.size()));
}

代码示例来源:origin: spinnaker/kayenta

@Override public void writeTo(OutputStream out) throws IOException {
  Buffer buffer = new Buffer();
  string.writeTo(buffer);
  buffer.writeTo(out);
 }
}

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

/** Write the contents of this to {@code out}. */
public Buffer writeTo(OutputStream out) throws IOException {
 return writeTo(out, size);
}

相关文章