Share on Google+Share on Google+

Use of rewind() method of FloatBuffer class.

In this tutorial you will see the use of rewind method of FloatBuffer class..

Use of rewind() method in float buffer class.

In this tutorial, we will see the Use of rewind method of FloatBuffer class.

FloatBuffer API:

The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following methods:

Return type Method Description
static FloatBuffer allocate( int capacity)  The allocate(..)method allocate a new float buffer.
final boolean hasRemaining() The hasRemaining() method tell whether there are any elements in buffer or not.
final Buffer rewind() The rewind() method set the position zero and content not change.


import java.nio.*;
import java.nio.FloatBuffer;
public class FloatBufferRewind {
  public static void main(String[] args) {
    FloatBuffer floatBuf = FloatBuffer.allocate(55);
  System.out.println("Contents in float buffer :");
    while (floatBuf.hasRemaining()) {
      System.out.print(floatBuf.get() ",");
    .print("After using rewind method 
    content of float buffer : \n"
    while (floatBuf.hasRemaining()) {
      System.out.print(floatBuf.get() ",");


C:\>java FloatBufferRewind
Contents in float buffer :
After using rewind method content of float buffer :

Download this code


Posted on: July 29, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null