import java.nio.*; import java.nio.ShortBuffer; public class ClearShortBuff { public static void main(String[] arg) { short[] array = new short[] { 2354, 666, 6677 }; ShortBuffer shortBuf = ShortBuffer.wrap(array); System.out.println("Value in a short buffer."); while (shortBuf.hasRemaining()) { System.out.println(shortBuf.get()); } shortBuf.clear(); shortBuf.flip(); int remainElement = shortBuf.remaining(); System.out.println("Number of remaining " + "elements in short buffer." + remainElement); if (remainElement == 0) { System.out.println("Clear."); } else { System.out.println("Not clear."); } } }