我搜索了这个错误,发现它通常发生在您尝试 GetContent 两次或更多次时,但问题是,我不是,我有两种几乎相同的方法,一种有效,另一种无效。
方法 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() - 作品
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();
...
}
我试图只调用 ParseHor(),但是当它进入 InputStream 行时,异常会随着 IllegalState 上升 - 内容已经消耗