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 :
Posted on: July 24, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles