public boolean put(byte[] dat) { if ((size + dat.length) > MAX_SIZE) { Log.e(TAG, "Dropped data. Size:" + size + " data length: " + dat.length); return false; } // Place data at the end of the buffer synchronized (buf) { buf.position(size); buf.put(dat); size = size + dat.length; buf.notify(); } return true; }