I have been trying to read a .doc and .docx file and assign the text in the file into a String variable in java but I keep having the error
Exception in thread "main" java.lang.Error: Unresolved compilation problems: The type org.apache.poi.poifs.filesystem.POIFSFileSystem cannot be resolved. It is indirectly referenced from required .class files The type org.apache.poi.poifs.filesystem.DirectoryNode cannot be resolved. It is indirectly referenced from required .class files
I have the following code to test the program
import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public class ReadDocFile
{
public static void main(String[] args)
{
File file = null;
WordExtractor extractor = null;
try
{
file = new File("c:\\test.doc");
FileInputStream fis = new FileInputStream(file.getAbsolutePath());
HWPFDocument document = new HWPFDocument(fis);
extractor = new WordExtractor(document);
String[] fileData = extractor.getParagraphText();
for (int i = 0; i < fileData.length; i++)
{
if (fileData[i] != null)
System.out.println(fileData[i]);
}
}
catch (Exception exep)
{
exep.printStackTrace();
}
}
}
I have downloaded a .jar file from
https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad/3.9
I think the .jar file that I imported is incomplete. If so, can anyone give me a link for the complete library?