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();
}
}
}