Let's be clear: These three methods are all methods defined by the Bytebuffer abstract base class buffer, and Bytebuffer only inherit them.
**************************************************** second, You need to understand the concept of buffer, which is the meaning of buffer, which is a linear finite sequence of elements of a particular primitive type. In addition to content, the basic properties of a buffer include capacity, limits, and location: the capacity of the buffer is the number of elements it contains. The capacity of the buffer cannot be negative and cannot be changed. The limit for a buffer is the first index of an element that should not be read or written. The limit for a buffer cannot be negative and cannot be greater than its capacity. The position of the buffer is the index of the next element to be read or written. The position of the buffer cannot be negative and cannot be greater than its limit. No insertion or reading can exceed the limit. tag, position, limit, and capacity values comply with the following invariant: 0 <= mark <= position <= limit <= capacity The newly created buffer always has a 0 position and an undefined tag. The initial limit can be 0, or it can be a different value, depending on the type of buffer and how it is constructed. In general, the initial contents of the buffer are undefined. Clear () Prepares the buffer for a series of new channel reads or relative placement operations: it sets the limit to the capacity size and sets the position to 0. Channel read refers to reading data from the channel into buffer, relative placement is to insert data into buffer starting from the location Flip () Prepares the buffer for a series of new channel writes or relative fetches: it sets the limit to the current position and then sets the position to 0. The limit is set to the current location in order to ensure the reliability of the data. The data that is written to the channel from buffer is the data that is indeed already present in buffer. Rewind () Prepares the buffer for re-reading the contained data: it keeps the limit unchanged and sets the position to 0. Similar to clear (), except that the three methods do not modify the data on the source code to make no changes to the buffer.
The Bytebuffer class's clear (), flip (), Rewind () method in the NIO package for Java