Hello All,
I tried
package com.hcl;
import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import org.apache.poi.poifs.filesystem.*;
public class WordDocCreation {
public static void main(String[] args) throws IOException
{
File file = new File("E:\\kalpana\\test1.doc");
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file));
HWPFDocument doc =new HWPFDocument(fs);
Range range = doc.getRange();
CharacterRun run = range.insertBefore("1. Hello World!!! It works well!!!");
run.setBold(true);
run.setItalic(true);
run.setCapitalized(true);
OutputStream out = new FileOutputStream("sample2.doc");
doc.write(out);
out.flush();
out.close();
}
}
But it gives an error as
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.poifs.filesystem.POIFSFileSystem.ge tRoot()Lorg/apache/poi/poifs/filesystem/DirectoryNode;
at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocume nt.java:146)
at com.hcl.WordDocCreation.main(WordDocCreation.java: 15)
Please suggest me...............
Looking forward for ur reply.