Java tutorial
//package com.java2s; import java.net.HttpURLConnection; import java.net.ProtocolException; public class Main { public static void setUpConnection(HttpURLConnection connection, String method) { try { connection.setRequestMethod(method); connection.setDoInput(true); connection.setDoOutput(true); connection.setRequestProperty("Content-Type", "application/json"); } catch (ProtocolException e) { e.printStackTrace(); } } }