code: public static void copyThenClose(InputStream input, OutputStream output)
        throws IOException {
      copy(input, output);
      input.close();
      output.close();
    }
docs: Copies information between specified streams and then closes
  both of the streams.
  @throws java.io.IOException