如何使用HttpURLConnection.getResponseCode()和HttpURLConnection.getErrorStream()获取errorstream?

时间:2014-01-16 03:02:35

标签: java http web

当我只使用HttpURLConnection.getErrorStream()时,我在HttpURLConnection.getErrorStream()之前使用HttpURLConnection.getResponseCode()时无法得到errstream.But,那么我可以得到errorstream。 像这样,我可以得到错误的声音:

if(urlconn.getResponseCode()>=400){
    is = urlconn.getErrorStream();
    System.out.println("error!!!");
    }else{
    is=urlconn.getInputStream();
    }
像这样,我无法得到错误,'是'是空的:

is = urlconn.getErrorStream();

0 个答案:

没有答案