public static String makeBytesUrlSafe(byte[] bytes) {
        byte[] encoded = Base64.encode(bytes);

        for (int i=0; i < encoded.length; i++) {
            switch(encoded[i]) {
                case '+':
                    encoded[i] = '-'; continue;
                case '=':
                    encoded[i] = '_'; continue;
                case '/':
                    encoded[i] = '~'; continue;
                default:
                    continue;
            }
        }
        return new String(encoded, UTF8);
    }
public static String makeBytesUrlSafe ( byte [ ] bytes ) { byte [ ] encoded = Base64 . encode ( bytes ) ; for ( int i = 0 ; i < encoded . length ; i ++ ) { switch ( encoded [ i ] ) { case '+' : encoded [ i ] = '-' ; continue ; case '=' : encoded [ i ] = '_' ; continue ; case '/' : encoded [ i ] = '~' ; continue ; default : continue ; } } return new String ( encoded , UTF8 ) ; }
Converts the given data to be safe for use in signed URLs for a private
distribution by using specialized Base64 encoding.