//从输入流读取返回内容InputStream is = null;int status = connection.getResponseCode();if(status>= HttpStatus.SC_BAD_REQUEST){ //此处一定要根据返回的状态码state来初始化输入流。如果为错误 is = connection.getErrorStream();}else{ //如果正确 is = connection.getInputStream();}