ODSingleXMLDocument.createFromStream error

6 views
Skip to first unread message

jeds...@gmail.com

unread,
Sep 21, 2018, 5:13:50 PM9/21/18
to jOpenDocument
Hello, I am trying to concatenate 2 odt files, but I am getting an exception at this line:

ODSingleXMLDocument.createFromStream(is)

error: exception in thread "main" org.jdom.input.JDOMParseException: Error on line 1: Content is not allowed in prolog.

source code:

package com.mycompany.jopendocument;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.jdom.JDOMException;
import org.jopendocument.dom.ODSingleXMLDocument;
import org.jopendocument.dom.OOUtils;

public class Main {

    public static void main(String[] args) throws JDOMException, IOException {
        File f1 = new File("c:/arquivos/arquivo1.odt");
        InputStream is = new FileInputStream(f1);
        ODSingleXMLDocument p1 = ODSingleXMLDocument.createFromStream(is);
        File f2 = new File("c:/arquivos/arquivo2.odt");
        ODSingleXMLDocument p2 = ODSingleXMLDocument.createFromPackage(f2);
        p1.add(p2);
        OOUtils.open(p1.saveToPackageAs(new File("cat")));
    }

}

The method createFromPackage works, but createFromStream does not work.

Reply all
Reply to author
Forward
0 new messages