question: public static final byte [ ] encodeUrl ( BitSet urlsafe , byte [ ] bytes ) { if ( bytes == null ) { return null ; } if ( urlsafe == null ) { urlsafe = WWW_FORM_URL ; } ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; for ( int i = 0 ; i < bytes . length ; i ++ ) { int b = bytes [ i ] ; if ( b < 0 ) { b = 256 + b ; } if ( urlsafe . get ( b ) ) { if ( b == ' ' ) { b = '+' ; } buffer . write ( b ) ; } else { buffer . write ( '%' ) ; char hex1 = Character . toUpperCase ( Character . forDigit ( ( b > > 4 ) & 0xF , 16 ) ) ; char hex2 = Character . toUpperCase ( Character . forDigit ( b & 0xF , 16 ) ) ; buffer . write ( hex1 ) ; buffer . write ( hex2 ) ; } } return buffer . toByteArray ( ) ; }
target:  Encodes an array of bytes into an array of URL safe 7-bit  characters. Unsafe characters are escaped.