Example usage for java.nio CharBuffer read

List of usage examples for java.nio CharBuffer read

Introduction

In this page you can find the example usage for java.nio CharBuffer read.

Prototype

public int read(CharBuffer target) throws IOException 

Source Link

Document

Reads characters from this buffer and puts them into target .

Usage

From source file:Main.java

public static void main(String[] args) throws IOException {
    CharBuffer cb1 = CharBuffer.allocate(20);
    cb1.append("java2s.com");
    cb1.rewind();//  w  w w.j av a2s  .c  o  m

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

    CharBuffer cb2 = CharBuffer.allocate(50);
    cb2.read(cb1);

    System.out.println(cb2);

}