In this tutorial, we will explain the use of
rewind() method of Buffer class. The ByteBuffer class
is a container for handling data.The ByteBuffer class is available in java.nio package.
In this example, The rewind method reset the position of buffer at zero.
So you can again
read the buffer. The method allocate( int capacity) of ByteBuffer class creates a new byte
buffer. The FileChannel class creates a channel for reading, and writing file. The channel can
read write both, but stream can either read-only or write-only. The getChannel method of
FileInputStream class returns the channel associated with this file input stream. The read()
method of FileChannel class fills byte buffer created by using allocate() method.
Without rewind the content of buffer :
After using rewind content of buffer :
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.