How does a `Buffer` function in Java NIO?
A `Buffer` allows data to be written in random order, and can be directly mapped into memory for faster data manipulation.
Thatâ€™s partially correct. Buffers can be mapped to memory for faster access, but the data is typically written sequentially to ensure integrity.
Can you explain how the `flip()` method is used in buffers to prepare data for reading?