Example usage for java.nio CharBuffer get

List of usage examples for java.nio CharBuffer get

Introduction

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

Prototype

public CharBuffer get(char[] dest, int off, int len) 

Source Link

Document

Reads chars from the current position into the specified char array, starting from the specified offset, and increases the position by the number of chars read.

Usage

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.allocate(5);
    cb1.put(2, 'j');
    cb1.rewind();/*from  ww w .  java 2s.c  om*/

    char[] charArray = new char[5];
    cb1.get(charArray, 0, 2);
    System.out.println(Arrays.toString(charArray));

}

From source file:eu.stratosphere.types.StringValue.java

/**
 * Sets the contents of this string to the contents of the given <tt>CharBuffer</tt>.
 * The characters between the buffer's current position (inclusive) and the buffer's
 * limit (exclusive) will be stored in this string.
 *  /*from  ww  w.j av a  2s.  co  m*/
 * @param buffer The character buffer to read the characters from.
 */
public void setValue(CharBuffer buffer) {
    Validate.notNull(buffer);
    final int len = buffer.length();
    ensureSize(len);
    buffer.get(this.value, 0, len);
    this.len = len;
    this.hashCode = 0;
}