[英]HttpEntity content already consumed
I searched about this error and i found it usually happen when you try to GetContent twice or more times, but the thing is, i am not, i have two almost identical methods, one works, the other don't.. 我搜索了此错误,发现当您尝试两次或多次获取GetContent时通常会发生这种情况,但事实是,我没有,我有两种几乎相同的方法,一种可行,而另一种却没有。
Method ParseHor() -Doesn't work 方法ParseHor()-不起作用
public ArrayList<Hor> ParseHor() throws Exception{
ArrayList<Horario> listHorario = new ArrayList<Horario>();
HttpGet get = new HttpGet(
URL1);
HttpResponse response = httpClient.execute(get);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent(); // Create an InputStream with the
BufferedReader reader = new BufferedReader(new InputStreamReader(is,
"iso-8859-1"));
StringBuilder sb = new StringBuilder();
...
}
ParseGrades() - Works ParseGrades()-作品
public ArrayList<Grade> ParseGrades() throws Exception {
HttpGet get = new HttpGet(
URL2);
HttpResponse response = httpClient.execute(get);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent(); // Create an InputStream with the
BufferedReader reader = new BufferedReader(new InputStreamReader(is,
"iso-8859-1"));
StringBuilder sb = new StringBuilder();
...
}
I tried to call just ParseHor(), but when it gets on the InputStream line, the exception rises with IllegalState - Content already consumed 我试图只调用ParseHor(),但是当它到达InputStream行时,异常随IllegalState一起出现-内容已被消耗
找到它,问题在于变量的名称是相同的,我对此进行了更改并开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.