Home Tutorial Java Corejava Nio Reads the character at buffer's current position.

 
 

Reads the character at buffer's current position.
Posted on: July 27, 2010 at 12:00 AM
Advertisement
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

Advertisement

Related Tags for Reads the character at buffer's current position.:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 27, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com