Пример #1
1
 // encodeURL
 public static String encodeURL(String url, String encode) throws UnsupportedEncodingException {
   StringBuilder sb = new StringBuilder();
   StringBuilder noAsciiPart = new StringBuilder();
   for (int i = 0; i < url.length(); i++) {
     char c = url.charAt(i);
     if (c > 255) {
       noAsciiPart.append(c);
     } else {
       if (noAsciiPart.length() != 0) {
         sb.append(URLEncoder.encode(noAsciiPart.toString(), encode));
         noAsciiPart.delete(0, noAsciiPart.length());
       }
       sb.append(c);
     }
   }
   return sb.toString();
 }
Пример #2
1
  static void toHexString(String header, ByteBuffer buf) {
    sb.delete(0, sb.length());

    for (int index = 0; index < buf.limit(); index++) {
      String hex = Integer.toHexString(0x0100 + (buf.get(index) & 0x00FF)).substring(1);
      sb.append((hex.length() < 2 ? "0" : "") + hex + " ");
    }
    LOG.debug(
        "hex->"
            + header
            + ": position,limit,capacity "
            + buf.position()
            + ","
            + buf.limit()
            + ","
            + buf.capacity());
    LOG.debug("hex->" + sb.toString());
  }