Skip to content

Instantly share code, notes, and snippets.

@johnbeadle
Created August 24, 2017 17:01
Show Gist options
  • Select an option

  • Save johnbeadle/a39698577fb7074bd7c378160c65f08a to your computer and use it in GitHub Desktop.

Select an option

Save johnbeadle/a39698577fb7074bd7c378160c65f08a to your computer and use it in GitHub Desktop.
if (this.postData != null) {
OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
Iterator<?> keys = postData.keys(); // get the object keys
// loop through them
while( keys.hasNext() ) {
String key = (String)keys.next(); //get the postData key
if ( postData.get(key) instanceof JSONObject ) {
// do something else
} else if( postData.get(key) instanceof String) {
writer.write(key+"="+postData.get(key)+"&");
}
}
writer.flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment