Example usage for java.nio ShortBuffer isDirect

List of usage examples for java.nio ShortBuffer isDirect

Introduction

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

Prototype

public abstract boolean isDirect();

Source Link

Document

Indicates whether this buffer is direct.

Usage

From source file:Main.java

public static void main(String[] args) {
    ShortBuffer bb = ShortBuffer.allocate(10);
    bb.put((short) 100);
    System.out.println(bb.isDirect());

}

From source file:Main.java

public static ShortBuffer clone(final ShortBuffer buf) {
    if (buf == null) {
        return null;
    }//from w ww .  j  a va 2s  . co  m
    buf.rewind();

    final ShortBuffer copy;
    if (buf.isDirect()) {
        copy = createShortBuffer(buf.limit());
    } else {
        copy = createShortBufferOnHeap(buf.limit());
    }
    copy.put(buf);

    return copy;
}