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.

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

Ads