「Android」response.getStatusLine().getStatusCode()の使い方

サンプルコード
public static InputStream get(String url)throws IOException ,Exception {

urlStr = url;
isConnecting = true;

HttpGet httpGet = new HttpGet(urlStr);
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters,
connectionTimeout);

DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpResponse response = httpClient.execute(httpGet);

if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = response.getEntity();
inputStream = entity.getContent();
return inputStream;}
else return null;

}
}

Android

Posted by arkgame