static long streamLength(InputStream in) ctex {
  temp tempCloseStream(in);
  byte[] buf = new byte[65536];
  long total = 0;
  while (true) {
    int n = in.read(buf);
    if (n <= 0) break;
    total += n;
  }
  ret total;
}