Home Tutorial Java Corejava Nio Wraps a character sequence into a buffer.

 
 

Wraps a character sequence into a buffer.
Posted on: July 26, 2010 at 12:00 AM
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

Advertisement

Related Tags for Wraps a character sequence into 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 26, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com