Reads the character at buffer's current position.


 

Reads the character at buffer's current position.

In this tutorial you will see how to read the character at buffer's current position.

In this tutorial you will see how to read the character at buffer's current position.

Reads the character at buffer's current position.

In this tutorial you will see how to read the character at buffer's current position. The get method actually get the value from current position and increment its position also. 

Code:

import java.nio.CharBuffer;

public class CharBufferDemo {
  public static void main(String[] args) {
    char[] chr = new char[] { 'a''b''c''d''e' };
    CharBuffer charbuffer1 = CharBuffer.allocate(10);
    charbuffer1.put(chr);
    charbuffer1.rewind();
    for (int i = 0; i < charbuffer1.length(); i++)
      System.out.print(" " + charbuffer1.get());
  }
}

Output:

  a b c d e

Download this code

Ads