Here you can find the source of makeUrlRequest(String surl, String data, String method)
public static String makeUrlRequest(String surl, String data, String method) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static String makeUrlRequest(String surl, String data, String method) throws IOException { URL url = new URL(surl); HttpURLConnection con;//w ww . j a v a2s . co m con = (HttpURLConnection) url.openConnection(); con.setRequestMethod(method); con.setRequestProperty("User-Agent", "EBA Client"); con.setRequestProperty("Accept-Language", "en-US,en;q=0.5"); con.setDoOutput(true); DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes(data); wr.flush(); wr.close(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); return response.toString(); } }