Here you can find the source of post(String url, String content)
public static String post(String url, String content) throws IOException
//package com.java2s; //License from project: LGPL import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; public class Main { public static String post(String url, String content) throws IOException { URL u = new URL(url); URLConnection c = u.openConnection(); c.setDoOutput(true);// ww w . j av a 2s . c om writeToStream(c.getOutputStream(), content); return getStreamContent(c.getInputStream()); } public static void writeToStream(OutputStream os, String content) throws IOException { OutputStreamWriter writer = new OutputStreamWriter(os); writer.write(content); writer.flush(); writer.close(); } public static String getStreamContent(InputStream is) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String c = "", line; while ((line = reader.readLine()) != null) c += "\n" + line; return c.substring(1); } }