Unable to access web with HttpURLConnection
String https_url = "http://www.google.com/";
URL url;
try {
url = new URL(https_url);
HttpURLConnection con = (HttpURLConnection)url.openConnection();
int responsecode = con.getResponseCode();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
In con.getResponseCode() gives error.
How to solve this?
|