随笔 - 100  文章 - 50  trackbacks - 0
<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(3)

随笔分类

随笔档案

文章分类

文章档案

收藏夹

我收藏的一些文章!

搜索

  •  

最新评论

阅读排行榜

评论排行榜

/**
 *
 */
package com.lin;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;

import javax.net.ssl.SSLHandshakeException;

/**
 * @author lin
 *
 */
public class TestURL {

 /**
  * @param args
  */
 public static void main(String[] args)   {
  String result = "";
  try {
   java.net.URL url = new java.net.URL("http://mail.163.com");
   HttpURLConnection httpConn = (HttpURLConnection) url
     .openConnection();
   httpConn.setDoOutput(true);
   httpConn.setDoInput(true);
   httpConn.setRequestMethod("POST");
   PrintWriter out = new PrintWriter(httpConn.getOutputStream());
   out.println("Email=test@gmail.com" +"password=123456");
   out.flush();
   out.close();
   BufferedReader in = new BufferedReader(new InputStreamReader(
     httpConn.getInputStream(), "UTF-8"));
   String line;
   while ((line = in.readLine()) != null) {
    result += line + "\n";
   }
   System.out.println("result: " + result);
   in.close();
    }catch(SSLHandshakeException se){
   System.out.println("error is open");
  }
  catch (Exception e) {
   System.out.println("sucess " + e);
  }

 }
}

posted on 2010-04-02 01:14 fly 阅读(921) 评论(0)  编辑  收藏 所属分类: java学习

只有注册用户登录后才能发表评论。


网站导航: