if (conn != null) { if (conn instanceof HttpURLConnection) {  ((HttpURLConnection) conn).disconnect(); } }
disconnect(conn);
    public InputStream openStream(URL url) throws IOException {        URLConnection conn = null;        InputStream inStream = null;        try {            conn = url.openConnection();            inStream = conn.getInputStream();            ByteArrayOutputStream outStream = new ByteArrayOutputStream();                        byte[] buffer = new byte[4096];            int len;            while ((len = inStream.read(buffer)) > 0) {                outStream.write(buffer, 0, len);            }            return new ByteArrayInputStream(outStream.toByteArray());        }        finally {            if (inStream != null) {                inStream.close();            }                        if (conn != null) {                if (conn instanceof HttpURLConnection) {                    //System.out.println("Closing HttpURLConnection");                    ((HttpURLConnection) conn).disconnect();                }            }        }    }