public static void partialURLEncodeVal(Appendable dest,String val) throws IOException {
  for (int i=0; i < val.length(); i++) {
    char ch=val.charAt(i);
    if (ch < 32) {
      dest.append('%');
      if (ch < 0x10)       dest.append('0');
      dest.append(Integer.toHexString(ch));
    }
 else {
switch (ch) {
case ' ':
        dest.append('+');
      break;
case '&':
    dest.append("%26");
  break;
case '%':
dest.append("%25");
break;
case '=':
dest.append("%3D");
break;
case '+':
dest.append("%2B");
break;
default :
dest.append(ch);
break;
}
}
}
}

public static void partialURLEncodeVal ( Appendable dest , String val ) throws IOException { for ( int i = 0 ; i < val . length ( ) ; i ++ ) { char ch = val . charAt ( i ) ; if ( ch < 32 ) { dest . append ( '%' ) ; if ( ch < 0x10 ) dest . append ( '0' ) ; dest . append ( Integer . toHexString ( ch ) ) ; } else { switch ( ch ) { case ' ' : dest . append ( '+' ) ; break ; case '&' : dest . append ( "%26" ) ; break ; case '%' : dest . append ( "%25" ) ; break ; case '=' : dest . append ( "%3D" ) ; break ; case '+' : dest . append ( "%2B" ) ; break ; default : dest . append ( ch ) ; break ; } } } }
urlencodes a value , replacing only enough chars so that the url may be unambiguously pasted back into a browser . < p > characters with a numeric value less than 32 are encoded . & amp ; , = , % , + , space are encoded .
