How do you parse the contents of a .odt file into a string in Java?
Frage
Preferable using the ODFDOM API. I would like to have the entire file's contents in a string, if possible. If not, how would you search the file for a specific substring?
Thanks in advance.
Lösung
you will need to load the odt document and then get the content root. From there, get the text content which will return you a string. So that should give you an idea on how to search using string? For example:
TextDocument document = TextDocument.loadDocument("test.odt");
String texts = document.getContentRoot().getTextContent());
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow