static void copyStreamWithPrints(InputStream in, OutputStream out, S pat) ctex { byte[] buf = new byte[65536]; int total = 0; while (true) { int n = in.read(buf); if (n <= 0) return; out.write(buf, 0, n); total += n; if (++total % 100000 == 0) print(pat.replace("{*}", str(total))); } }