当在android中以字符串形式键入URL时,在类型转换中会出现不获取response...error的情况。
public String abc(String url)
{
{
try
{
URL a = new URL(url);
HttpURLConnection http = (HttpURLConnection)a.openConnection();
http.setRequestMethod("get");
int res = http.getResponseCode();
String s = String.valueOf(res);
Log.i("", s);
}
catch(Exception e)
{
}
}
return null;
}
}
发布于 2015-06-23 23:20:38
get
应该是GET
http.setRequestMethod("GET");
int response = http.getResponseCode();
Log.i("response", Integer.toString(response));
https://stackoverflow.com/questions/31019984
复制