read Short Array from ByteBuffer - Java java.nio

Java examples for java.nio:ByteBuffer Read

Description

read Short Array from ByteBuffer

Demo Code


import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import javax.vecmath.Vector2d;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector4d;

public class Main{
    public static short[] readShortArray(ByteBuffer bf, int size) {

        short xx[] = new short[size];

        for (int i = 0; i < size; i++) {
            xx[i] = bf.getShort();//from  ww  w  .java2  s. c  om
        }

        return xx;
    }
}

Related Tutorials