In this tutorial you will see use of rewind method in java.In this tutorial you will see use of rewind method in java.
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 :