code: private static void streamCopy(InputStream is, OutputStream os, byte[] buf, boolean close) throws IOException {
          int len;
          if (buf == null) {
              buf = new byte[4096];
          }
          while ((len = is.read(buf)) > 0) {
              os.write(buf, 0, len);
          }
          os.flush();
          if (close) {
              is.close();
          }
      }
docs: Copy the contents of is to os.
  @param is
  @param os
  @param buf Can be null
  @param close If true, is is closed after the copy.
  @throws IOException