Example usage for java.nio CharBuffer duplicate

List of usage examples for java.nio CharBuffer duplicate

Introduction

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

Prototype

public abstract CharBuffer duplicate();

Source Link

Document

Returns a duplicated buffer that shares its content with this buffer.

Usage

From source file:MainClass.java

public static void main(String[] argv) throws Exception {
    CharBuffer buffer = CharBuffer.wrap("01234567");

    buffer.position(3).limit(6).mark().position(5);

    CharBuffer dupeBuffer = buffer.duplicate();

    buffer.clear();//  w ww.  j av a 2 s.  co m

    println(buffer);
    println(dupeBuffer);

    dupeBuffer.reset();
    println(dupeBuffer);

    dupeBuffer.clear();
    println(dupeBuffer);
}