public static List<Model> getJSONResource(String path) throws Exception {
URL url = new URL(path);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setConnectTimeout(5000);
connection.setRequestMethod("GET");
Log.v("radom","5");
if (connection.getResponseCode() == 200) {
InputStream inputStream = connection.getInputStream();
Log.v("radom","2");
return parserJSON(inputStream);
}else{
throw new RuntimeException("服务器响应失败");
}
}
代码执行到InputStream那里,也就是创建输入流对象,就不执行了是什么原因阿?我用输出检测的,只输出5,不输出2。如果把if语句去掉,也还是不输出2