Java网络请求getInputStream异常

今天调试网络请求部分时,当getInputStream失败时直接抛出异常。解决方法时在getInputStream之前获取ResponseCode 

if( connection.getResponseCode() != HttpURLConnection.HTTP_OK) return null;

  

你可能感兴趣的:(Inputstream)