I\'ve seen many different examples of using HttpURLConnection + InputStream, and closing them (or not closing them) after use. This is what I came up with to make sure every
There is also the new (with Java 7) 'try()' technique
try (OutputStream os = http.getOutputStream()) { os.write(out); }
Basically, it will auto-close anything in the try() statement, regardless of whether it is successful or not.