Code example for ByteBuffer

Methods: array, arrayOffset, hasArray, limit, position

0
         
    } 
    private  final int getArray(ByteBuffer in){
        if(in.hasArray()){
            input = in.array();
            inEnd = in.limit();
            return in.position()+savedInputHeldLen;/*exclude the number fo bytes held in previous conversion*/
        }else{ 
            inEnd = in.remaining();
            // BEGIN android-added 
            if (allocatedInput == null || (inEnd > allocatedInput.length)) {
                allocatedInput = new byte[inEnd];
            } 
            input = allocatedInput;
            // END android-added 
            // save the current position 
            int pos = in.position();
            in.get(input,0,inEnd);
            // reset the position 
            in.position(pos);
            // the start position   
            // of the new buffer   
            // is whatever is savedInputLen 
            return savedInputHeldLen;
        }