Here you can find the source of cleanBuffer(final ByteBuffer bb)
public static void cleanBuffer(final ByteBuffer bb)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static void cleanBuffer(final ByteBuffer bb) { bb.rewind();// w w w .j av a 2s . c o m int remain = 0; while ((remain = bb.remaining()) > 0) { final int r = remain & 0x7; if (r == 0) { bb.putLong(0L); } else { if ((r & 0x4) != 0) { bb.putInt(0); } if ((r & 0x2) != 0) { bb.putShort((short) 0); } if ((r & 0x1) != 0) { bb.put((byte) 0); } } } } }