http长连接异常处理情况

try {
    URL a = new URL(args[0]);
   URLConnection urlc = a.openConnection();
   is = conn.getInputStream();
    int ret = 0;
   while ((ret = is.read(buf)) > 0) {
      processBuf(buf);
    }
    // close the inputstream
    is.close();
} catch (IOException e) {
   try {
        respCode = ((HttpURLConnection)conn).getResponseCode();
       es = ((HttpURLConnection)conn).getErrorStream();
       int ret = 0;
        // read the response body
        while ((ret = es.read(buf)) > 0) {
            processBuf(buf);
       }
       // close the errorstream
        es.close();
    } catch(IOException ex) {
       // deal with the exception
   }
}

你可能感兴趣的:(http)