jOpenDocument


A pure Java library for OASIS Open Document files manipulation

Merge mutiple text files

jOpenDocument allows you to concatenate multiple text documents.


+
=

  // Load 2 text documents
  File f1 = new File("template/ooo2flyer_p1.odt");
  ODSingleXMLDocument p1 = ODSingleXMLDocument.createFromPackage(f1);

  File f2 = new File("template/ooo2flyer_p2.odt");
  ODSingleXMLDocument p2 = ODSingleXMLDocument.createFromPackage(f2);

  // Concatenate them
  p1.add(p2);

  // Save to file and Open the document with OpenOffice.org !
  OOUtils.open(p1.saveToPackageAs(new File("cat")));
Java2html

First you load the documents that you want to concatenate. Then you use the add() method and save the resulting document (the .odt extension is automatically added).

All the sytles are properly merged.

If you want to know more, look at the package org.jopendocument.dom

The complete example is located in org/jopendocument/sample/TextCat.java