Here you can find the source of handleURLEncodedResponse(HttpResponse response)
public static Map handleURLEncodedResponse(HttpResponse response)
//package com.java2s; import java.io.IOException; import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.protocol.HTTP; public class Main { public static Map handleURLEncodedResponse(HttpResponse response) { Map<String, Charset> map = Charset.availableCharsets(); Map<String, String> oauthResponse = new HashMap<String, String>(); Set<Map.Entry<String, Charset>> set = map.entrySet(); Charset charset = null;//from w w w . jav a 2s . co m HttpEntity entity = response.getEntity(); System.out.println(); System.out .println("********** URL Encoded Response Received **********"); for (Map.Entry<String, Charset> entry : set) { System.out.println(String.format(" %s = %s", entry.getKey(), entry.getValue())); if (entry.getKey().equalsIgnoreCase(HTTP.UTF_8)) { charset = entry.getValue(); } } try { List<NameValuePair> list = URLEncodedUtils.parse(entity); for (NameValuePair pair : list) { System.out.println(String.format(" %s = %s", pair.getName(), pair.getValue())); oauthResponse.put(pair.getName(), pair.getValue()); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new RuntimeException( "Could not parse URLEncoded Response"); } return oauthResponse; } }