/** This utility is verbose as we have a minimum java version of 6 */ static void skipAllContent(HttpURLConnection connection) throws IOException { InputStream in = connection.getInputStream(); IOException thrown = skipAndSuppress(in); if (thrown == null) return; InputStream err = connection.getErrorStream(); if (err != null) skipAndSuppress(err); // null is possible, if the connection was dropped throw thrown; }