HttpURLConnection example

HttpURLConnection allows to open an HTTP connection and get a response.

URL url = new URL("http://www.tutoref.com");
HttpURLConnection http = (HttpURLConnection)url.openConnection();
int statusCode = http.getResponseCode();
// if statusCode == 200, it means it's ok.
// other ways, it's an error you can deal with it.

 

You like this content ? Share it with you entourage !

Leave a Reply

Your email address will not be published.