private static void copy(InputStream input, OutputStream output, byte[] buffer)
            throws IOException {
      int n;
      while ((n = input.read(buffer)) != -1) {
        output.write(buffer, 0, n);