title: HttpURLConnection Closing IO Streams
body: <p>I am new to Java and HttpURLConnection. Should I close the opened IO streams before dropping the connection. If I close the streams, should I need to drop the connection as well? Which is the proper way of implementation?</p>
  
  <pre><code>try {
  String uri = "http://localhost:8081/RESTEASY/saju/post/text";
  URL url = new URL(uri);
  connection =
      (HttpURLConnection) url.openConnection();
  connection.setRequestMethod("POST");
  connection.setRequestProperty("Accept", "text/plain");
  connection.setRequestProperty("Content-Type", "text/plain");
  connection.setDoOutput(true);
  
  OutputStream os = connection.getOutputStream();
  
  //bla bla
  
  System.out.println(connection.getResponseCode());
  InputStream iStream = connection.getInputStream();
  
  //bla bla
  
  } catch (MalformedURLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }finally{
      // os.close(); - IS THIS REQUIRED
      // iStream.close(); - IS THIS REQUIRED
      connection.disconnect();    
  }
  }
  </code></pre>