You may obtain the http status line with the following code:

httpStatusLine = urlConnection.g etHeaderFields( ).get(null).get (0);

Having this status, you just have to extract the status code :

static final Pattern HTTP_STATUS_COD E_PATTERN=Patte rn.compile("(\\ d{3})");
Matcher matcher = HTTP_STATUS_COD E_PATTERN.match er(httpStatusLi ne);
if (matcher.find() ){
httpCode = matcher.group(1 );...