Java IO Tutorial - Java ShortBuffer.slice()








Syntax

ShortBuffer.slice() has the following syntax.

public abstract ShortBuffer slice()

Example

In the following code shows how to use ShortBuffer.slice() method.

import java.nio.ShortBuffer;
import java.util.Arrays;
//w w w  .  j a v  a 2 s . c om
public class Main {
  public static void main(String[] args) {
    ShortBuffer shortBuffer = ShortBuffer.allocate(10);
    shortBuffer.put((short)100);
    
    shortBuffer.rewind();
    
    
    ShortBuffer shortBuffer2 = shortBuffer.slice();
    
    System.out.println(shortBuffer2.equals(shortBuffer2));

  }
}

The code above generates the following result.