public static void serialize(JCas jcas, CTAKESSerializer type, boolean prettyPrint,
                                 OutputStream stream) throws SAXException, IOException {
        if (type == CTAKESSerializer.XCAS) {
            XCASSerializer.serialize(jcas.getCas(), stream, prettyPrint);
        } else if (type == CTAKESSerializer.XMI) {
            XmiCasSerializer.serialize(jcas.getCas(), jcas.getTypeSystem(), stream, prettyPrint,
                    new XmiSerializationSharedData());
        } else {
            XmlCasSerializer.serialize(jcas.getCas(), jcas.getTypeSystem(), stream);
        }
    }
Serializes a CAS in the given format.

@param jcas        CAS (Common Analysis System) to be serialized.
@param type        type of cTAKES (UIMA) serializer used to write CAS.
@param prettyPrint {@code true} to do pretty printing of output.
@param stream      {@link OutputStream} object used to print out information
                   extracted by using cTAKES.
@throws SAXException if there was a SAX exception.
@throws IOException  if any I/O error occurs.
tika-parsers/tika-parsers-ml/tika-parser-nlp-module/src/main/java/org/apache/tika/parser/ctakes/CTAKESUtils.java