URL url =new URL("http://www.google.com");
BufferedReader br=new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));
String line="";
while((line=br.readLine())!=null){
System.out.println(line);
}这样是get方式发的请求,用post怎么搞

解决方案 »

  1.   

    用httpClient吧:
    http://blog.csdn.net/lcllcl987/archive/2006/09/28/1301421.aspx
      

  2.   

    如果要使用URL类,需要设置一个属性
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    conn.setRequestProperty("Content-Type", "");
    if(cookie != null)
    conn.setRequestProperty("Cookie", cookie);
    PrintStream ps = new PrintStream(conn.getOutputStream(), false, "UTF-8");