In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the basic knowledge of java.nio.Buffer". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the basic knowledge of java.nio.Buffer".
Capacity (): indicates the size of the buffer. Once the size is determined, it cannot be changed.
Limit (): tells you how many bytes have been filled into the buffer so far, or use # limit (int) to change this limit
Position (): tells you the current location to perform the next read / write operation
Mark (): remember a location for later reset with reset ()
Flip (): swap limit pointers and position pointers, then set the position to 0 and discard the mark tags that have been made.
The basic operations of the buffer are reading # get () and writing # put ().
Buffer type:
NIO has seven specific Buffer types, each of which corresponds to a basic data type (except boolean)
ByteBuffer / / byte buffer CharBuffer / / character buffer DoubleBuffer / / double buffer FloatBuffer / / float buffer IntBuffer / / int buffer LongBuffer / / long buffer ShortBuffer / / short buffer
Buffers are divided into direct buffers and indirect buffers. The creation cost of direct buffers is higher than that of indirect buffers, but it also provides faster access speed. So direct buffers are suitable for long-standing buffers, while indirect buffers are suitable for those with a shorter life cycle. Also, note that only ByteBuffer can create direct buffers.
Changes in several internal states of the buffer:
Capacity (capacity), buffer size
Limit (limit), an index of * * bytes that should not be read or written, always less than the capacity.
Position, the index of the next byte to be read or written, is always less than the limit.
0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.