It gives 2 same strings as unequal.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Amit kumarJha wrote:Below program will convert .doc to .txt file:-
import java.io.*;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
public class ReadDocFile {
public static void main(String[] args) {
File file = null;
try {
// Read the Doc/DOCx file
file = new File("D:\\New.docx");
FileInputStream fis = new FileInputStream(file.getAbsolutePath());
XWPFDocument doc = new XWPFDocument(fis);
XWPFWordExtractor ex = new XWPFWordExtractor(doc);
String text = ex.getText();
//write the text in txt file
File fil = new File("D:\\New.txt");
Writer output = new BufferedWriter(new FileWriter(fil));
output.write(text);
output.close();
} catch (Exception exep) {
}
}
}
Also upload the xmlbeans-2.3.0,dom4j-1.6.1 and stax-api-1.0.1.
Download the Apache POI jar also.
Monica Marcus wrote:the code works for doc files. My problem is with docx files only.
Monica Marcus wrote:The problem is that I need to use two jar files: poi-3-0-alpha3.jar (for the doc files) and poi-3.9-20121203.jar (for the docx files)
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|