Code example for ByteBuffer

Methods: get, getShort, position

0
    /** 
     * @param buffer 
     * @return  
     */ 
    public static int getSmartA(ByteBuffer buffer) {
        int i = buffer.get(buffer.position()) & 0xFF;
        if(i < 128)
            return (buffer.get() & 0xFF) - 64;
        else  
            return (buffer.getShort() & 0xFFFF) - 49152;
    } 
     
    /** 
     * @param buffer 
     * @return  
     */ 
    public static int getSmartB(ByteBuffer buffer) {
        int i = buffer.get(buffer.position()) & 0xFF;
        if(i < 128)
            return (buffer.get() & 0xFF);
        else