public int coderesult (String urlstring) throws Exception {
URL url = new URL(urlstring);
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
//System.out.println("Response code is " + httpCon.getResponseCode());
int mycode = httpCon.getResponseCode();
return mycode;
}
public int displaycode () {
int dispcode = 0;
try {
dispcode = coderesult(myurl);
}
catch (MalformedURLException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally {
}
return dispcode;
}
android studio在“dispcode=coderesult(myurl);”中显示错误:未处理exception:java.lang.exception"
2条答案
按热度按时间5t7ly7z51#
你的
codeResult()
方法抛出Exception
```public int coderesult (String urlstring) throws Exception {
catch(Exception ex){
ex.printStackTrace();
}
nvbavucw2#
用这个
写下