当前位置:网站首页>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.
边栏推荐
- What is the difference between SAP ERP and ORACLE ERP?
- How to find all fields with empty data in sql
- 2022软件测试工程师最全面试题
- UE4 通过互动(键盘按键)开门
- Ali's local life's single-quarter revenue is 10.6 billion, Da Wenyu's revenue is 7.2 billion, and Cainiao's revenue is 12.1 billion
- UE4 opens doors with overlapping events
- UE4 后期处理体积 (角色受到伤害场景颜色变淡案例)
- iMedicalLIS listener (2)
- UE4 通过与其它Actor互动开门
- Leading the highland of digital medicine, Zhongshan Hospital explores to create a "new paradigm" for future hospitals
猜你喜欢
UE4 第一人称角色模板 添加生命值和调试伤害
token, jwt, oauth2, session parsing
【8.1】代码源 - 【第二大数字和】【石子游戏 III】【平衡二叉树】
Acid (ACID) Base (BASE) Principles for Database Design
The test salary is so high?20K just graduated
MySql的索引学习和使用;(本人觉得足够详细)
How to wrap markdown - md file
Hard power or soft power, which is more important to testers?
[GYCTF2020]EasyThinking
Getting Started with Kubernetes Networking
随机推荐
Bosses, I noticed that a mysql CDC connector parameters scan. The incremental. Sna
UE4 通过与其它Actor互动开门
Use Unity to publish APP to Hololens2 without pit tutorial
Open-Falcon of operation and maintenance monitoring system
public static <T> List<T> asList(T... a) 原型是怎么回事?
905. 区间选点
Shell script: for loop and the while loop
Detailed and comprehensive postman interface testing practical tutorial
The most comprehensive exam questions for software testing engineers in 2022
Android interview question - how to write with his hands a non-blocking thread safe queue ConcurrentLinkedQueue?
【8.1】代码源 - 【第二大数字和】【石子游戏 III】【平衡二叉树】
The test salary is so high?20K just graduated
iMedicalLIS监听程序(2)
队列题目:最近的请求次数
UE4 在游戏运行时更改变量 (通过鼠标滑轮来更改第一人称角色的最大行走速度)
Acid (ACID) Base (BASE) Principles for Database Design
Spark Basics [Introduction, Getting Started with WordCount Cases]
Index Mysql in order to optimize paper 02 】 【 10 kinds of circumstances and the principle of failure
rpc-remote procedure call demo
UE4 opens door via interaction (keyboard key)