FileOutputStream out = null;
try {
// write XMI
out = new FileOutputStream(name);
XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem());
XMLSerializer xmlSer = new XMLSerializer(out, false);
ser.serialize(aCas, xmlSer.getContentHandler());
} finally {
if (out != null) {
out.close();
}
}