public static String getResponseContent ( HttpResponse response ) throws IOException { final HttpEntity entity = response . getEntity ( ) ; if ( entity != null ) { try { ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; entity . writeTo ( out ) ; //call this in any case!!! return isScOk ( response ) ? new String ( out . toByteArray ( ) , Charset . forName ( "UTF-8" ) ) : null ; } finally { //ensure entity is closed. EntityUtils . consume ( entity ) ; } } else { return null ; } }
Get text content from the response if response status code is 200 .