public class HttpRequest { public static String doGet(String url,String params) throws Exception{ return null; } public static String doPost(String url,String params) throws Exception{ HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setDoInput(true); // conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); // conn.setRequestProperty("Connection", "Close"); // conn.setRequestProperty("Content-length", String.valueOf(params.length())); // conn.connect(); OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8"); out.write(params); out.flush(); out.close(); InputStreamReader r = new InputStreamReader(conn.getInputStream(), "UTF-8"); BufferedReader reader = new BufferedReader(r); String line = null; StringBuffer sb = new StringBuffer(); while ((line = reader.readLine()) != null) { sb.append(line); } return sb.toString(); } }