当前位置:网站首页>bytebuffer internal structure
bytebuffer internal structure
2022-08-05 03:59:00 【java continuous practice】
ByteBuffer internal structure
ByteBuffer important properties
- capacity: capacity. How much data can fit in the bytebuffer
- position: Read and write pointer. Index subscript
- limit: limit for reading and writing
In the beginning, the post is at the starting position, limit is the limit size of writing,
In write mode, 4 values are written, position moves 4 positions, limit is the capacity to write.
After calling flip() method, turn on read mode, postion starts reading from 0 again, limit moves from capacity position to topOne step to read the position of the data, because the write only writes to the position of d, no need to read the position of the capacity.
The state after reading 4 bytes, after calling the get() method, the position moves to the limit position, and the reading is completed.
After calling clear method, switch to write mode and position returns to 0, limit returns to the position of capacity, which means that data of capacity size can be written.
compact method: For some reason, the data must be written before the data is read. The following original data contains four bytes of abcd data. After reading ab, it is necessary to write the data and call compact.The method is to start writing data from d, instead of writing data from 0, which prevents data loss.
边栏推荐
- token, jwt, oauth2, session parsing
- Mathematics - Properties of Summation Symbols
- Developing Hololens encountered The type or namespace name 'HandMeshVertex' could not be found..
- leetcode-每日一题1403. 非递增顺序的最小子序列(贪心)
- 队列题目:最近的请求次数
- [BSidesCF 2019]Kookie
- [极客大挑战 2019]FinalSQL
- UE4 第一人称角色模板 添加生命值和调试伤害
- UE4 在游戏运行时更改变量 (通过鼠标滑轮来更改第一人称角色的最大行走速度)
- 四位数显表头设计
猜你喜欢
数据库设计的酸(ACID)碱(BASE)原则
2022-08-04T17:50:58.296+0800 ERROR Announcer-3 io.airlift.discovery.client.Announcer appears after successful startup of presto
商业智能BI业务分析思维:现金流量风控分析(一)营运资金风险
Web3.0 Dapps - the road to the future financial world
MySql index learning and use; (I think it is detailed enough)
Kubernetes 网络入门
UE4 第一人称角色模板 添加冲刺(加速)功能
Industry Status?Why do Internet companies prefer to spend 20k to recruit people rather than raise their salary to retain old employees~
多御安全浏览器新版下载 | 功能优秀性能出众
Index Mysql in order to optimize paper 02 】 【 10 kinds of circumstances and the principle of failure
随机推荐
如何解决复杂的分销分账问题?
Walter talked little knowledge | "remote passthrough" that something
Android Practical Development - Kotlin Tutorial (Introduction - Login Function Implementation 3.3)
Android interview question - how to write with his hands a non-blocking thread safe queue ConcurrentLinkedQueue?
rpc-remote procedure call demo
bytebuffer 使用demo
不看后悔,appium自动化环境完美搭建
UE4 更改组件变量 (以修改第一人称角色模板的最大行走速度和跳跃高度为例)
重载运算符
How to find all fields with empty data in sql
【8.3】代码源 - 【喵 ~ 喵 ~ 喵~】【树】【与】
Swing有几种常用的事件处理方式?如何监听事件?
Redis1: Introduction to Redis, basic features of Redis, relational database, non-relational database, database development stage
2022.8.4-----leetcode.1403
10 years of testing experience, worthless in the face of the biological age of 35
mutillidae下载及安装
UE4 通过互动(键盘按键)开门
新人如何入门和学习软件测试?
七夕节代码表白
[CISCN2019 华东南赛区]Web11