• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

i want to read an ODT file

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have created the file using Openoffice .org .When i read the file Its giving the junk value.Are there any api to read the content of the file that has extension of .ODT
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An .odt file is not a plain text file, so if you try to read it as if it is plain text, then you'll get "junk".

I have not used it myself, but there is a Java API for OpenOffice. Have a look at this:

http://api.openoffice.org/
http://weblogs.java.net/blog/tchangu/archive/2005/12/open_office_jav_1.html
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jodconverter is a nice library that uses OO to covert between file formats. Since OO understands ODF (of which ODT is part) it might help.

If you want a more direct approach, ODF (and ODT) files are XML files in a zip archive. So you can use the java.util.zip package to open the file, and then process its constituent files using the JAXP API. The file that has the actual content is called "content.xml".
 
Rancher
Posts: 4804
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
while its true that they are just zip'd XML files, one quick look at the structure of the XML is enough to make one run away and hide.

Thar be dragons....
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the ODF format rather straightforward to deal with. More for the learning effect than for the practical use I wrote an ODS->XLS converter and ODT->PDF/RTF/HTML converter a while ago.

The trickiest part was to reconcile the various styles that get applied, because there are default styles, document default styles, paragraph styles, local styles, etc., and you need to make sure which one gets applied to a particular piece of data.

Processing the actual text or cell contents was comparatively easy.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic