Example usage for java.nio ShortBuffer mark

List of usage examples for java.nio ShortBuffer mark

Introduction

In this page you can find the example usage for java.nio ShortBuffer mark.

Prototype

public final Buffer mark() 

Source Link

Document

Marks the current position, so that the position may return to this point later by calling reset().

Usage

From source file:Main.java

public static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer buf) {
    ByteBuffer dest = newByteBuffer(buf.remaining() * SIZEOF_SHORT);
    buf.mark();
    dest.asShortBuffer().put(buf);/*w w w.  j a v a  2s .com*/
    buf.reset();
    dest.rewind();
    return dest;
}