public final byte [ ] decode ( byte [ ] source , int off , int len ) { int len34 = len * 3 / 4 ; byte [ ] outBuff = new byte [ len34 ] ; // upper limit on size of output int outBuffPosn = 0 ; byte [ ] b4 = new byte [ 4 ] ; int b4Posn = 0 ; int i = 0 ; byte sbiCrop = 0 ; byte sbiDecode = 0 ; for ( i = off ; i < off + len ; i ++ ) { sbiCrop = ( byte ) ( source [ i ] & 0x7f ) ; // only the low seven bits sbiDecode = DECODABET [ sbiCrop ] ; if ( sbiDecode >= WHITE_SPACE_ENC ) { // white space, equals sign or better if ( sbiDecode >= PADDING_CHAR_ENC ) { b4 [ b4Posn ++ ] = sbiCrop ; if ( b4Posn > 3 ) { outBuffPosn += decode4to3 ( b4 , 0 , outBuff , outBuffPosn ) ; b4Posn = 0 ; // if that was the padding char, break out of 'for' loop if ( sbiCrop == PADDING_CHAR ) { break ; } } // end if: quartet built } // end if: equals sign or better } // end if: white space, equals sign or better else { //discard } } // each input character byte [ ] out = new byte [ outBuffPosn ] ; System . arraycopy ( outBuff , 0 , out , 0 , outBuffPosn ) ; return out ; }
Very low - level access to decoding ASCII characters in the form of a byte array .