Response from UrlConnection Java -


so far, have snippet.

urlconnection connection = null;         try {             connection = (new url("some_link")).openconnection();             connection.setconnecttimeout(5000);             connection.setreadtimeout(5000);             connection.connect();         } catch (ioexception e) {          } 

the possible response codes 200 , 404 , it's working fine when response code 200 (ok). question how can find response code received connection, example: if response code 404, throw exception , smth there.

make type of httpurlconnection. can use .getresponsecode();


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -