本文整理了Java中io.micronaut.core.io.buffer.ByteBuffer.asNioBuffer()
方法的一些代码示例,展示了ByteBuffer.asNioBuffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.asNioBuffer()
方法的具体详情如下:
包路径:io.micronaut.core.io.buffer.ByteBuffer
类名称:ByteBuffer
方法名:asNioBuffer
[英]Exposes this buffer's readable bytes as an NIO java.nio.ByteBuffer. The returned buffer shares the content with this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer. This method is identical to buf.nioBuffer(buf.readerIndex(), buf.readableBytes()). This method does not modify readerIndex or writerIndex of this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.
[中]将此缓冲区的可读字节公开为NIO java。尼奥。拜特伯弗。返回的缓冲区与此缓冲区共享内容,而更改返回的NIO缓冲区的位置和限制不会影响此缓冲区的索引和标记。此方法与buf相同。nioBuffer(buf.readerIndex(),buf。readableBytes()。此方法不修改此缓冲区的readerIndex或writerIndex。请注意,如果此缓冲区是动态缓冲区并且已调整其容量,则返回的NIO缓冲区将不会看到此缓冲区的更改。
代码示例来源:origin: micronaut-projects/micronaut-core
@Override
public ByteBuffer write(ByteBuffer... buffers) {
if (ArrayUtils.isNotEmpty(buffers)) {
ByteBuf[] byteBufs = Arrays.stream(buffers)
.map(buffer -> {
if (buffer instanceof NettyByteBuffer) {
return ((NettyByteBuffer) buffer).asNativeBuffer();
} else {
return Unpooled.wrappedBuffer(buffer.asNioBuffer());
}
}).toArray(ByteBuf[]::new);
return write(byteBufs);
}
return this;
}
代码示例来源:origin: micronaut-projects/micronaut-core
private void encodeInput(I input, InvokeRequest invokeRequest) {
if (input != null) {
ByteBuffer byteBuffer = jsonMediaTypeCodec.encode(input, byteBufferFactory).asNioBuffer();
invokeRequest.setPayload(byteBuffer);
}
}
代码示例来源:origin: micronaut-projects/micronaut-core
byteBuf = (ByteBuf) nativeBuffer;
} else {
byteBuf = Unpooled.wrappedBuffer(byteBuffer.asNioBuffer());
代码示例来源:origin: micronaut-projects/micronaut-core
byteBuf = (ByteBuf) nativeBuffer;
} else {
byteBuf = Unpooled.wrappedBuffer(byteBuffer.asNioBuffer());
内容来源于网络,如有侵权,请联系作者删除!