/**
*
*/
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 阅读(931)
评论(0) 编辑 收藏 所属分类:
java学习