Netty - NIO之ByteBuffer

 

一、ByteBuffer使用

 

 

 

 

二、ByteBuffer结构 

 

 

 

 

 

三、ByteBuffer常见API

3.1 分配空间 allocate V.S. allocateDirect

 

 

3.2 String ByteBuffer互相转换

String 转换为 Bytebuffer

 

 

Bytebuffer 转换为 String 

由于buffer1依然处于写模式,因此position指针指在了位置5的位置,直接decode会直接往后走,读不到想要的数据。

因此必须要选flip一下。

 

 

 

 

3.3 分散读scattering read,集中写 gathering read 

注意这里的思想,api倒是其次

 

 

 

posted on 2022-08-14 23:30  frank_cui  阅读(52)  评论(0)    收藏  举报

导航

levels of contents