The documentation for HttpURLConnection already has an example of how to POST data to a server. I've elaborated on it a little to show creation of the JSONObject and writing the data to the OutputStream.
try {
// Create parameters JSONObject
String[] jsonArray = new String[] { "abc", "sdsf", "sfsd" };
JSONObject parameters = new JSONObject();
parameters.put("foldername", "imageFolder");
parameters.put("jsonArray", new JSONArray(Arrays.asList(jsonArray)));
parameters.put("location", "Dhaka");
// Open connection to URL and perform POST request.
URL url = new URL("https://example.com/folder/something");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true); // Set Http method to POST
urlConnection.setChunkedStreamingMode(0); // Use default chunk size
// Write serialized JSON data to output stream.
OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, "UTF-8"));
writer.write(parameters.toString());
// Close streams and disconnect.
writer.close();
out.close();
urlConnection.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}