//这只是一个网络请求数据的代码
public class HttpQing {
public static String Http(String path){
URL url;
try {
url = new URL(path);
//2,通过URL获取连接。
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//3,设置请求方式。
conn.setRequestMethod("GET");
//4,设置连接超时时间。
conn.setConnectTimeout(5000);
//6,获取响应码
int code = conn.getResponseCode();
if (code==200) {
//获取服务器响应的数据
InputStream stream = conn.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(stream));
String str=null;
StringBuilder builder=new StringBuilder();
while((str=br.readLine())!=null){
builder.append(str);
}
String json=builder.toString();
return json;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}