httpurlconnection get -凯发k8网页登录

那些青春的岁月

  凯发k8网页登录-凯发天生赢家一触即发官网 :: 凯发k8网页登录首页 :: 联系 :: 聚合  :: 管理
  500 posts :: 0 stories :: 135 comments :: 0 trackbacks

package com.abin.lii.han.limei;

import java.io.bufferedreader;
import java.io.inputstreamreader;
import java.net.httpurlconnection;
import java.net.url;

import org.junit.test;

public class imediaregistertest {
 @test
 public void testimediaregister(){
  string limei_http="";
  string appid="fk000";
  string udid="3a5s4d6f8g9k_3596140444464123";
  string requesturl=limei_http "?app=" appid "&udid=" udid "&source=" "where"";
  system.out.println(requesturl);
  string result="";
  try {
   url url=new ;
   httpurlconnection connection=(httpurlconnection)url.openconnection();
   connection.setdooutput(true);
   connection.setdoinput(true);
   connection.setrequestmethod("get");
   connection.setusecaches(false);
   // urlconnection.setinstancefollowredirects是成员函数,仅作用于当前函数
   connection.setinstancefollowredirects(false);
   connection.setrequestproperty("content-type",
                "application/x-www-form-urlencoded");
   connection.connect();
   //发送执行请求
   
   //接收返回请求
   bufferedreader reader=new bufferedreader(new inputstreamreader(connection.getinputstream(),"gbk"));
   string line="";
   stringbuffer buffer=new stringbuffer();
   while((line=reader.readline())!=null){
    buffer.append(line);
   }
   result=buffer.tostring();
   system.out.println("result=" result);
   connection.disconnect();
  } catch (exception e) {
   e.printstacktrace();
  }
 }

}

posted on 2013-01-06 21:36 abin 阅读(2439) 评论(1)     所属分类: httpurlconnection

feedback

# re: httpurlconnection get 2016-08-03 16:03
是  回复  
  


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


网站导航:
              
 
网站地图