Code example for ByteBuffer

Methods: positiongetgetShort

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);
Stop searching for code, let great code find you!  Add Codota to your java IDE