public class Main {     /** 
     * @param args the command line arguments 
     */ 
    public static void main(String[] args) { 
        // TODO code application logic here 
        Main m = new Main(); 
        m.getHttpText("http://mail.sohu.com/");//搜狐邮箱地址 
    } 
    public void getHttpText(String str){ 
    try { 
         
        URL url = new URL(str); 
        URLConnection uc = url.openConnection(); 
        uc.setDoOutput(true);         OutputStream raw = uc.getOutputStream(); 
        OutputStream buf = new BufferedOutputStream(raw); 
        OutputStreamWriter out = new OutputStreamWriter(buf, "gb2312"); 
        out.write("username=test520520&password=222222");//用户名 和密码 
        out.flush(); 
        out.close();         InputStream in = uc.getInputStream(); 
        in = new BufferedInputStream(in); 
        Reader r = new InputStreamReader(in); 
        int c; 
        System.out.println("---------------------------------"); 
        while ((c = r.read()) != -1) 
              System.out.print((char) c); 
        in.close(); 
        System.out.println("---------------------------------"); 
    } catch (IOException e) { 
        e.printStackTrace(); 
    } }