CharBuffer: array() : CharBuffer « java.nio « Java by API






CharBuffer: array()

 
import java.nio.CharBuffer;

public class Main {
  public static void main(String[] argv) throws Exception {
    CharBuffer cb = CharBuffer.allocate(100);

    cb.put("This is a test String");

    cb.flip();

    System.out.println("hasArray() = " + cb.hasArray());

    char[] carray = cb.array();

    System.out.print("array=");

    for (int i = 0; i < carray.length; i++) {
      System.out.print(carray[i]);
    }

  }
}

   
  








Related examples in the same category

1.CharBuffer: allocate(int capacity)
2.CharBuffer: arrayOffset()
3.CharBuffer: capacity()
4.CharBuffer: flip()
5.CharBuffer: get()
6.CharBuffer: hasArray()
7.CharBuffer: hasRemaining()
8.CharBuffer: limit()
9.CharBuffer: limit(int newLimit)
10.CharBuffer: position()
11.CharBuffer: put(char c)
12.CharBuffer: put(String str)
13.CharBuffer: slice()
14.CharBuffer: subSequence(int start, int end)
15.CharBuffer: wrap(CharSequence csq)
16.CharBuffer: wrap(char[] array, int offset, int length)