Hallo,
um eine Word-Datei auslesen zu können hab ich in eclipse Apache POI installiert und die Libary in das Projekt hinzugefügt. Wenn ich jedoch es auslesen lassen möchte kommt eine NoClassDefFoundError. Ich verstehe es nicht, da die Datei auf meinem Desktop existiert. Ich gehe euch mal das Dokument weiter.
Wäre dankbar wenn ihr mir helfen könntet.
um eine Word-Datei auslesen zu können hab ich in eclipse Apache POI installiert und die Libary in das Projekt hinzugefügt. Wenn ich jedoch es auslesen lassen möchte kommt eine NoClassDefFoundError. Ich verstehe es nicht, da die Datei auf meinem Desktop existiert. Ich gehe euch mal das Dokument weiter.
Wäre dankbar wenn ihr mir helfen könntet.
Code:
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
public class hier {
public static void readDocxFile(String fileName) {
try {
File file = new File(fileName);
FileInputStream fis = new FileInputStream(file.getAbsolutePath());
XWPFDocument document = new XWPFDocument(fis);
List<XWPFParagraph> paragraphs = document.getParagraphs();
System.out.println("Total no of paragraph "+paragraphs.size());
for (XWPFParagraph para : paragraphs) {
System.out.println(para.getText());
}
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args)
{
readDocxFile("C:\\Users\\(meinName)\\Desktop\\da.docx");
}
}