Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How To DOC File Convert TO Html in java?

870192Sep 2 2011 — edited Sep 2 2011
How To DOC File Convert TO Html in java?

import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.rtf.RTFEditorKit;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public void doctohtml() throws FileNotFoundException, IOException {
WordExtractor extractor = null;

String TemplateFile = "";
String TempFileData;

FileInputStream is = new FileInputStream("C:\\Yes.doc");
HWPFDocument document = new HWPFDocument(is);


extractor = new WordExtractor(document);

String[] fileData = extractor.getParagraphText();

for (int i = 0; i < fileData.length; i++) {
if (fileData[i] != null) {
TempFileData = fileData;
TemplateFile = TemplateFile + TempFileData;

}
}
System.out.println(TemplateFile);

StringWriter writer = new StringWriter();
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();

htmlEditorKit.write(writer, document, 0, len); this document is not lenght function...


String a = writer.toString();
System.out.println("==>"+a); // a is html tag.. But htmlEditor.write don't read ==> document.lenght(); this function not found

I wann Doc convert to Html tag
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 30 2011
Added on Sep 2 2011
2 comments
540 views