Java tutorial
//package com.java2s; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static HttpURLConnection buildConnection(String url, String requestMethod) throws IOException { HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection(); /*set request*/ con.setRequestMethod(requestMethod); con.setRequestProperty("Accept-Language", "UTF-8"); con.setDoOutput(true); return con; } public static HttpURLConnection buildConnection(String url) throws IOException { HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection(); /*set request*/ con.setRequestProperty("Accept-Language", "UTF-8"); return con; } }