Java IO Tutorial - Java CharBuffer.put(String src)








Syntax

CharBuffer.put(String src) has the following syntax.

public final CharBuffer put(String src)

Example

In the following code shows how to use CharBuffer.put(String src) method.

/* w w w. j  a v  a  2s.co  m*/
import java.nio.CharBuffer;

public class Main {
  public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.allocate(5);
    cb1.put("java2s.com");
    cb1.rewind();

    System.out.println(cb1.toString());
  }
}