Convert DOC file to DOCX with Java

3rgo picture 3rgo · Jul 12, 2011 · Viewed 18.2k times · Source

I need to use DOCX files (actually the XML contained in them) in a Java software I'm currently developing, but some people in my company still use the DOC format.

Do you know if there is a way to convert a DOC file to the DOCX format using Java ? I know it's possible using C#, but that's not an option

I googled it, but nothing came up...

Thanks

Answer

Shahzad Latif picture Shahzad Latif · Oct 4, 2011

You may try Aspose.Words for Java. It allows you to load a DOC file and save it as DOCX format. The code is very simple as shown below:

// Open a document.  
Document doc = new Document("input.doc"); 
// Save document. 
doc.save("output.docx");

Please see if this helps in your scenario.

Disclosure: I work as developer evangelist at Aspose.