Home Tutorial Java Corejava Nio Get the capacity of a buffer

 
 

Share on Google+Share on Google+
Get the capacity of a buffer
Posted on: July 24, 2010 at 12:00 AM
Advertisement
In this tutorial you will learn about how get the capacity of a buffer

Get the capacity of a buffer

In this tutorial we will see how to get size of buffer using capacity() method.

Code:

import java.nio.CharBuffer;

public class CharBufferCapacityDemo {
  public static void main(String[] args) {
    CharBuffer charbuffer1 = CharBuffer.allocate(6);
    charbuffer1.put('B').put('U').put('F').put('F').put('E').put('R');
    System.out.println(charbuffer1.capacity());
  }
}

Output:

  6

Download this code

Advertisement

Related Tags for Get the capacity of a buffer:


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.

Posted on: July 24, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com