var surl = "https://www.baidu.com";
//var surl = "http://cf.ams.game.qq.com/ams/ame/amesvr?sServiceType=cf&iActivityId=306817";
//var aurl = plus.android.newObject("java.net.URL",surl);
var URL = plus.android.importClass("java.net.URL");
var aurl = new URL(surl);
//var con = plus.android.newObject("java.net.HttpURLConnection",aurl.openConnection());
var HttpURLConnection = plus.android.importClass("java.net.HttpURLConnection");
var con = new HttpURLConnection();
con = aurl.openConnection();
//plus.android.invoke(con,"setConnectTimeout","300");
//plus.android.invoke(con,"setRequestMethod","GET");
//plus.android.invoke(con,"connect");
con.setConnectTimeout(3000);
con.setRequestMethod("GET");
//con.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
//con.setDoOutput(true);
con.connect();
var InputStream = plus.android.importClass("java.io.InputStream");
var inputstream = new InputStream();
var inputstream = con.getInputStream();
var BufferedReader = plus.android.importClass("java.io.BufferedReader");
var bufferedReader = new BufferedReader();
var InputStreamReader = plus.android.importClass("java.io.InputStreamReader");
bufferedReader = new InputStreamReader(inputstream, "utf-8");
var line="",acceptData="";
//line = bufferedReader.readLine();
line =plus.android.invoke(bufferedReader,"readLine");
while (line != null) { //不为空进行操作
acceptData += line;
//line = bufferedReader.readLine();
line = plus.android.invoke(bufferedReader,"readLine");
}
console.log(acceptData,line);
console.log(con.getResponseCode());//200说明访问成功了
2 个回复
2***@qq.com
同问
bianyuan456