title: how to get the negative response code in java
body: <p>I am using the code as follows in java.</p>
  
  <pre><code> URL url = new URL("any url");
  
    HttpURLConnection conn=(HttpURLConnection) url.openConnection();
  
    InputStream in = conn.getInputStream();
  
    int responseCode= conn.getResponseCode();
  </code></pre>
  
  <p>Here I am getting the issue:-
     for some url,I am getting the negative reponseCode,that is <code>'-1'</code>.and it is getting terminated,it is not going further,so please help me,how to solve or how to handle such errors.</p>