Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes .doc files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ".doc files" Watch ".doc files" New topic
Author

.doc files

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
im trying to insert text into a template .doc file, and you can treat word
files as just plain text.

but I was talking to my professor and he said he thought that java had packages that could deal with .doc files, but not .docx files which is 2007 encryption i guess.

can anyone elaborate on this anymore, like for instance the actual package to look for.

Justin


You down with OOP? Yeah you know me!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41884
    
  63
Java does not have classes that can deal with .doc or .docx files. Some limited access is possible through the Jakarta POI library, but inserting text may already be beyond it.

I understand that .docx is an XML format (albeit an undocumented one, unless you count a 6000 page document as 'documentation'), so Java code could access those through the JAXP API. I doubt that that does you any good unless you have mastered the 6000 pages, though.


Ping & DNS - my free Android networking tools app
Tony VanHorn
Ranch Hand

Joined: Dec 13, 2006
Posts: 74
Any of the 2007 office components are using XML format, hence the .docx. They have done this so that you can take advantage of a feature that allows you to hover over formatting changes and see what the document will look like without having to actually select the change and then hit undo or choose a different one. You should be able to unzip the .docx file into its different parts, which include the XML for the main content.
Jeff Ash
Greenhorn

Joined: Apr 07, 2007
Posts: 11
You might look at the Apache Jakarta project called POI. It's free and open-source. It allows you to interact with various Microsoft OLE documents such as Word and Excel. I have played with it a little, but not enough to give you any guidance. You can find it at:
http://jakarta.apache.org/poi/index.html


Jeff Ash<br /><a href="http://www.excellentiasoftware.com" target="_blank" rel="nofollow">Excellentia Software</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: .doc files