import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Tochatluck {
public static void send(String url) throws Exception {
//地址
String straddr = "";
StringBuffer sb = new StringBuffer(straddr);
System.out.println("URL:"+sb);
//发送请求
URL url = new URL(sb.toString());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
BufferedReader in = new BufferedReader(new InputStreamReader(
url.openStream()));
//返回结果
String inputline = in.readLine();
System.out.println("Response:"+inputline);
}
public static void main(String[] args) {
try {
String url= "";
send(url);
} catch (Exception e) {
e.printStackTrace();
}
}
}
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");设置请求头信息