static byte[] loadBinaryPage(String url) ctex { print("Loading " + url); return loadBinaryPage(new URL(url).openConnection()); } static byte[] loadBinaryPage(URLConnection con) ctex { setHeaders(con); ret loadBinaryPage_noHeaders(con); } static byte[] loadBinaryPage_noHeaders(URLConnection con) ctex { ByteArrayOutputStream buf = new ByteArrayOutputStream(); InputStream inputStream = con.getInputStream(); long len = 0; try { len = con.getContentLengthLong(); } catch (Throwable e) { printStackTrace(e); } int n = 0; while (true) { int ch = inputStream.read(); if (ch < 0) break; buf.write(ch); if (++n % 100000 == 0) println(" " + n + (len != 0 ? "/" + len : "") + " bytes loaded."); } inputStream.close(); return buf.toByteArray(); }