Created
May 13, 2014 09:52
-
-
Save fiskurgit/1bb7139d21c4b3db82ec to your computer and use it in GitHub Desktop.
Original Google volley encodeParameters method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts <code>params</code> into an application/x-www-form-urlencoded encoded string. | |
*/ | |
private byte[] encodeParameters(Map<String, String> params, String paramsEncoding) { | |
StringBuilder encodedParams = new StringBuilder(); | |
try { | |
for (Map.Entry<String, String> entry : params.entrySet()) { | |
encodedParams.append(URLEncoder.encode(entry.getKey(), paramsEncoding)); | |
encodedParams.append('='); | |
encodedParams.append(URLEncoder.encode(entry.getValue(), paramsEncoding)); | |
encodedParams.append('&'); | |
} | |
return encodedParams.toString().getBytes(paramsEncoding); | |
} catch (UnsupportedEncodingException uee) { | |
throw new RuntimeException("Encoding not supported: " + paramsEncoding, uee); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment