Share on Google+Share on Google+

Wraps a character sequence into a buffer.

Advertisement
In this tutorial you will see how to wraps a character sequence into a buffer.

Wraps a character sequence into a buffer.

In this tutorial you will see how to wraps a character sequence into a buffer.
Here in this example a string variable is having a sequence of character which is further wrapped into a buffer. 

Code:

import java.nio.CharBuffer;

public class CharBufferDemo1 {
  public static void main(String[] args) {
    String str = "abcdefghijklmnop";
    CharBuffer charbuffer1 = CharBuffer.wrap(str);
    charbuffer1.rewind();
    System.out.println(charbuffer1.length());
  }
}

Output:

  16

Download this code

Advertisements

Advertisement

Posted on: July 26, 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.