文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>简单的java post 数据

简单的java post 数据

时间:2010-07-18  来源:pk3589


package test;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

import java.net.URL;
import java.net.URLConnection;

public class JavaPostTest {

        public String post() throws Exception{
                URL url = new URL("http://www.renren.com/PLogin.do");
                
                URLConnection conn = url.openConnection();
                
                conn.setDoOutput(true);
                
                OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
                
                writer.write("[email protected]&password=123");
                
                writer.flush();
                
                writer.close();
                
                InputStreamReader reder  = new InputStreamReader(conn.getInputStream(),"utf-8");
                
                BufferedReader breader = new BufferedReader(reder);
                
                BufferedWriter w = new BufferedWriter(new FileWriter("d:/1.txt"));
                
                String content = null;
                String result = null;
                while((content=breader.readLine())!=null){
                        result+=content+"\n";
                }
                w.write(result);
                w.flush();
                w.close();
                return result;
                
                
        }
        
        public static void main(String[] args) throws Exception{
                JavaPostTest post  = new JavaPostTest();
                String aa = post.post();
                String bb = new String(aa.getBytes("utf-8"));
                System.out.println(bb);
                
        }
        
}

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载