Я использую этот код для отправки запроса на http-сервер:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost( "http://192.168.0.1/test.php" );
HttpResponse response = null;
try {
List< NameValuePair > nameValuePairs = new ArrayList< NameValuePair >( 1 );
nameValuePairs.add( new BasicNameValuePair( "num", "2" ) );
post.setEntity( new UrlEncodedFormEntity( nameValuePairs ) );
response = client.execute( post );
}
catch( ClientProtocolException e ) {
...
}
catch( IOException e ) {
...
}
Ответ - не что иное, как простая строка
. Как я могу прочитать этот ответ как строку
? Не похоже, что у HttpResponse есть метод для этого напрямую.