} else { if (sb == null) { sb = new StringBuffer(); sb.append(new String(bytes, 0, i)); } sb.append("%");
} if (sb == null) { sb = new StringBuffer(); sb.append(new String(bytes, 0, i)); } sb.append("%");
    public static String uriEncode(String src) {        StringBuffer sb = null;        byte[] bytes;        try {            bytes = src.getBytes("UTF-8");        } catch (UnsupportedEncodingException e) {            bytes = src.getBytes();        }        for (int i = 0; i < bytes.length; i++) {            int index = bytes[i] & 0xFF;            if (uri_char_validity[index] > 0) {                if (sb != null) {                    sb.append((char) bytes[i]);                }                continue;            } else {                if (sb == null) {                    sb = new StringBuffer();                    sb.append(new String(bytes, 0, i));                }                sb.append("%");                sb.append(Character.toUpperCase(Character.forDigit((index & 0xF0) >> 4, 16)));                sb.append(Character.toUpperCase(Character.forDigit(index & 0x0F, 16)));            }        }        return sb == null ? src : sb.toString();    }