Java IO Tutorial - Java ShortBuffer.get(short[] dst, int offset, int length)








Syntax

ShortBuffer.get(short[] dst, int offset, int length) has the following syntax.

public ShortBuffer get(short[] dst,  int offset,  int length)

Example

In the following code shows how to use ShortBuffer.get(short[] dst, int offset, int length) method.

//from ww w  .  ja v  a2  s  .  c o  m
import java.nio.ShortBuffer;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    ShortBuffer bb = ShortBuffer.allocate(10);
    bb.put((short)100);
    
    bb.rewind();
    
    short[] shortArray = new short[10];
    bb.get(shortArray,0,2);
    
    System.out.println(Arrays.toString(shortArray));

  }
}

The code above generates the following result.