I opened the attached document "tutorial.doc" and added a new para and saved the document (attached as tutorialop.doc). When I open tutorialop.doc in MS Word, MS word shows an error on document open saying some tables in the document have been corrupted and asks me to use the repair document option.
The document can be got from https://docs.google.com/open?id=0B1wVJ9Jz7lCeYTdESk5wM2RNOFU The output that got generated can be got from https://docs.google.com/open?id=0B1wVJ9Jz7lCeUVk0NGt3aWZHMmM
The code i used to do the changes is as below: I have added this to the main in QuickTest.java that comes with the POI HWPF source code. HWPFDocument doc = new HWPFDocument (new FileInputStream ("C:/tutorial.doc")); Range r = doc.getRange(); System.out.println("Example you supplied:"); System.out.println("---------------------"); Section s = r.getSection(0); Paragraph p = s.getParagraph(1); p.insertAfter("KC KC KC"); OutputStream out = new FileOutputStream("C:/tutorialOp.doc"); doc.write(out); out.close();