code: public static void copy(XMLStreamReader source, OutputStream sink)
              throws XMLStreamException {
          XMLOutputFactory factory = XMLOutputFactory.newInstance();
          XMLStreamWriter writer = factory.createXMLStreamWriter(sink, "UTF-8");
          copy(source, writer);
          writer.flush();
      }
docs: Copies the subtree that the reader is currently position at to the
  given stream. The reader must be positioned at a START_ELEMENT
  event, and when finished, will be positioned on the corresponding
  END_ELEMENT event.
  <p>
  <b>NOTE:</b> Even if successful, this does not currently ensure that
  the output has all used namespaces declared. In particular, if a
  namespace was previously declared in the XML that the reader saw,
  then used within the scope of the elements being copied but no
  re-declared within them, the output will not be self-contained.
  
  @param source the reader whose subtree should be copied.
  @param sink the stream to write to (UTF-8 encoding will be used).
  It will be left open when finished.
  @throws XMLStreamException if anything goes wrong during the copy.