本文整理了Java中okio.Buffer.snapshot()
方法的一些代码示例,展示了Buffer.snapshot()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.snapshot()
方法的具体详情如下:
包路径:okio.Buffer
类名称:Buffer
方法名:snapshot
[英]Returns an immutable copy of this buffer as a byte string.
[中]以字节字符串形式返回此缓冲区的不可变副本。
代码示例来源:origin: square/retrofit
@Override public RequestBody convert(T value) throws IOException {
Buffer buffer = new Buffer();
adapter.encode(buffer, value);
return RequestBody.create(MEDIA_TYPE, buffer.snapshot());
}
}
代码示例来源:origin: amitshekhariitbhu/Fast-Android-Networking
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: square/okio
@Override public ByteString encodeUtf8(String s) {
Buffer buffer = new Buffer();
buffer.writeUtf8(s);
return buffer.snapshot();
}
};
代码示例来源:origin: square/okio
@Override public ByteString decodeHex(String hex) {
Buffer buffer = new Buffer();
buffer.write(ByteString.decodeHex(hex));
return buffer.snapshot();
}
代码示例来源:origin: square/okio
@Test public void snapshotReportsAccurateSize() {
Buffer buf = new Buffer().write(new byte[] { 0, 1, 2, 3 });
assertEquals(1, buf.snapshot(1).size());
}
}
代码示例来源:origin: square/okio
@Test public void accessByteByByteReverse() throws Exception {
Buffer buffer = bufferFactory.newBuffer();
try (UnsafeCursor cursor = buffer.readUnsafe()) {
byte[] actual = new byte[(int) buffer.size()];
for (int i = (int) (buffer.size() - 1); i >= 0; i--) {
cursor.seek(i);
actual[i] = cursor.data[cursor.start];
}
assertEquals(ByteString.of(actual), buffer.snapshot());
}
}
代码示例来源:origin: square/okio
@Test public void accessByteByByte() throws Exception {
Buffer buffer = bufferFactory.newBuffer();
try (UnsafeCursor cursor = buffer.readUnsafe()) {
byte[] actual = new byte[(int) buffer.size()];
for (int i = 0; i < buffer.size(); i++) {
cursor.seek(i);
actual[i] = cursor.data[cursor.start];
}
assertEquals(ByteString.of(actual), buffer.snapshot());
}
}
代码示例来源:origin: square/okio
@Test public void accessByteByByteAlwaysResettingToZero() throws Exception {
Buffer buffer = bufferFactory.newBuffer();
try (UnsafeCursor cursor = buffer.readUnsafe()) {
byte[] actual = new byte[(int) buffer.size()];
for (int i = 0; i < buffer.size(); i++) {
cursor.seek(i);
actual[i] = cursor.data[cursor.start];
cursor.seek(0L);
}
assertEquals(ByteString.of(actual), buffer.snapshot());
}
}
代码示例来源:origin: com.graphhopper/directions-api-client
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: jamorham/xDrip-plus
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: AzureAD/azure-activedirectory-library-for-android
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: kubernetes-client/java
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: NightscoutFoundation/xDrip
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: io.kubernetes/client-java-api
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: com.neotys.ascode/swagger-java-client
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: de.adorsys.multibanking/finapi-adapter
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: org.renci.io.swagger/swagger-java-comet-client
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: AzureAD/azure-activedirectory-library-for-android
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: com.walmartlabs.concord/concord-client
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
代码示例来源:origin: Tickaroo/tikxml
/**
* Checks for DOCTYPE beginning {@code <!DOCTYPE }. This method doesn't consume the opening <!DOCTYPE
* Tag
*
* @return true, if DOCTYPE opening tag, otherwise false
* @throws IOException
*/
private boolean isDocTypeDefinition() throws IOException {
return buffer.size() >= DOCTYPE_OPEN.size() &&
buffer.snapshot(DOCTYPE_OPEN.size()).toAsciiUppercase().equals(DOCTYPE_OPEN);
}
内容来源于网络,如有侵权,请联系作者删除!