Docx4JWordTemplate { public void writeAsOPCXml(OutputStream out) throws IOException { try { SaveToZipFile saveToZipFile = new SaveToZipFile(wordMLPackage); saveToZipFile.saveFlatOPC(out); } catch (Docx4JException e) { unwrapIOException(e); throw new WteException("Can not marshall document", e); } finally { IOUtils.closeQuietly(out); } } Docx4JWordTemplate();  Docx4JWordTemplate(InputStream in); PlainTextContent addPlainTextContent(); List<PlainTextContent> getPlainTextContent(); void writeAsOPCXml(OutputStream out); void writeAsOpenXML(OutputStream out); void writeAsPDF(OutputStream out);  }
@Test public void writeAsOPCXmlTest() throws IOException, Docx4JException, JAXBException { Docx4JWordTemplate doc = new Docx4JWordTemplate(); File file = File.createTempFile("test", "docx"); OutputStream out = FileUtils.openOutputStream(file); try { doc.writeAsOPCXml(out); } finally { IOUtils.closeQuietly(out); } String content = FileUtils.readFileToString(file); assertTrue(content.startsWith("<?xml")); }