Java IO Tutorial - Java CharBuffer.append(char c)








Syntax

CharBuffer.append(char c) has the following syntax.

public CharBuffer append(char c)

Example

In the following code shows how to use CharBuffer.append(char c) method.

import java.nio.CharBuffer;
import java.util.Arrays;
/*from w ww .  ja  v  a2s  . com*/
public class Main {
  public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.allocate(5);
    cb1.append('j');
    cb1.rewind();


    System.out.println(Arrays.toString(cb1.array()));


  }
}

The code above generates the following result.