I request your collaboration due to the fact that I am consuming information from a website and I do not know what the problem is that is generating me, because in some requests I can do String mensaje = EntityUtils.toString(entity);
and it works, but I just made the implementation for another method and I can not do it anymore, I get the following: java.io.IOException: Attempted read from closed stream.
; the implementation in the following:
public void buscarRadicado(HttpClient httpclient, HttpPost httpost) throws Exception
{
List <NameValuePair> nameValuePair = null;
HttpResponse response = null;
HttpEntity entity = null;
try
{
{
for(int index = 0; index < 10 ; ++index )
{
httpost = new HttpPost("path");
// Parametros de la consulta
nameValuePair = new ArrayList <NameValuePair>();
nameValuePair.add(new BasicNameValuePair("submit", "CONSULTAR"));
nameValuePair.add(new BasicNameValuePair("cod_tipo", "25"));
nameValuePair.add(new BasicNameValuePair("no_int", 123456));
nameValuePair.add(new BasicNameValuePair("uno", ""));
httpost.setEntity(new UrlEncodedFormEntity(nameValuePair, Consts.UTF_8));
response = response = httpclient.execute(httpost);
entity = response.getEntity();
mensaje = EntityUtils.toString(entity);
EntityUtils.consume(entity);
entity = null;
httpost = null;
response = null;
guardarMensaje(mensaje);
mensaje = "se guardo Correctamente";
}
}
catch (ClientProtocolException e)
{
httpost.releaseConnection();
httpclient.getConnectionManager().shutdown();
}
catch (IOException e)
{
e.printStackTrace();
httpost.releaseConnection();
httpclient.getConnectionManager().shutdown();
}
}
Response code: response.getStatusLine().getStatusCode()
200
Content-Type: response.getEntity().getContentType();
text / html