Example usage for java.nio LongBuffer get

List of usage examples for java.nio LongBuffer get

Introduction

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

Prototype

public abstract long get(int index);

Source Link

Document

Returns the long at the specified index; the position is not changed.

Usage

From source file:Main.java

public static void main(String[] args) {
    LongBuffer bb = LongBuffer.allocate(10);
    bb.put(100);/*from  ww w. j ava2 s.  c om*/

    bb.rewind();
    System.out.println(bb.get(0));

}

From source file:Main.java

public static void main(String[] args) {
    LongBuffer bb = LongBuffer.allocate(10);
    bb.put(100);/*from w  w w .  j  av a 2 s . c  o  m*/

    bb.rewind();

    long[] longArray = new long[10];
    bb.get(longArray);

    System.out.println(Arrays.toString(longArray));

}

From source file:org.libimobiledevice.ios.driver.binding.services.ScreenshotService.java

private byte[] takeScreenshotAsTiff() throws SDKException {

    PointerByReference ptr = new PointerByReference();
    LongBuffer sizeptr = LongBuffer.allocate(1);

    int res = screenshot_service_take_screenshot(service, ptr, sizeptr);

    if (ptr == null) {
        throw new SDKException("Bug ? pointer should have been assigned by the screenshot service");
    } else if (ptr.getValue() == null) {
        throw new SDKException("Didn't get a value back. Something wrong in screenshot_service");
    } else {//www  .j ava2  s .  c  om
        long size = sizeptr.get(0);
        byte[] b = ptr.getValue().getByteArray(0, (int) size);
        return b;
    }
}

From source file:ubic.basecode.io.ByteArrayConverter.java

/**
 * @param barray//from   www  .ja v  a 2  s. c  o  m
 * @return long[] resulting from parse of the bytes.
 */
public long[] byteArrayToLongs(byte[] barray) {
    if (barray == null)
        return null;

    LongBuffer buf = ByteBuffer.wrap(barray).asLongBuffer();
    long[] array = new long[buf.remaining()];
    buf.get(array);

    return array;
}