/**
   * Closes this content.
   *
   * @throws IOException if an error occurs.
   */
  public void close() throws IOException {
    if (finished) {
      return;
    }

    // Close the output stream
    IOException exc = null;
    try {
      content.close();
    } catch (final IOException ioe) {
      exc = ioe;
    }

    // Notify of end of output
    exc = null;
    try {
      onClose();
    } catch (final IOException ioe) {
      exc = ioe;
    }

    finished = true;

    if (exc != null) {
      throw exc;
    }
  }