HttpURLConnection异常处理
下面的代码,如果因为网络或者其他因素,导致httpURLConnection参数无法正确获取,就会导致错误,那么一般的错误会有哪些呢?
如何对这些错误情况进行分类一下,例如,网络的原因,server的原因等等
我现在只知道SocketTimeoutException,FileNotFoundException,IOException,其他的都用Exception捕获的,
但是不是非常清楚这些错误。
URL url = new URL(urlString); httpURLConnection = (HttpURLConnection)url.openConnection();httpURLConnection.setDoOutput(true); httpURLConnection.setUseCaches(false); httpURLConnection.setRequestMethod("POST"); httpURLConnection.connect();httpURLConnection.getInputStream();