public static Map<String,String> toKeyValuePairs(String httpString,boolean performUrlDecode){
  if (httpString == null || httpString.length() == 0) {
    return null;
  }
  Map<String,String> keyValuePairs=new HashMap<String,String>();
  StringTokenizer st=new StringTokenizer(httpString);
  String newToken=null;
  String param, val;
  int equalSignInd;
  while (st.hasMoreTokens() && (newToken=st.nextToken("&")) != null) {
    equalSignInd=newToken.indexOf("=");
    param=newToken;
    val="";
    if (equalSignInd > -1) {
      param=newToken.substring(0,equalSignInd);
      val=newToken.substring(equalSignInd + 1);
    }
    if (performUrlDecode) {
      param=StringUtils.urlDecode(param);
      val=StringUtils.urlDecode(val);
    }
    keyValuePairs.put(param,val);
  }
  return keyValuePairs;
}

public static Map < String , String > toKeyValuePairs ( String httpString , boolean performUrlDecode ) { if ( httpString == null || httpString . length ( ) == 0 ) { return null ; } Map < String , String > keyValuePairs = new HashMap < String , String > ( ) ; StringTokenizer st = new StringTokenizer ( httpString ) ; String newToken = null ; String param , val ; int equalSignInd ; while ( st . hasMoreTokens ( ) && ( newToken = st . nextToken ( "&" ) ) != null ) { equalSignInd = newToken . indexOf ( "=" ) ; param = newToken ; val = "" ; if ( equalSignInd > - 1 ) { param = newToken . substring ( 0 , equalSignInd ) ; val = newToken . substring ( equalSignInd + 1 ) ; } if ( performUrlDecode ) { param = StringUtils . urlDecode ( param ) ; val = StringUtils . urlDecode ( val ) ; } keyValuePairs . put ( param , val ) ; } return keyValuePairs ; }
convert http request string into key - value pairs
