3
當我試圖實現以下如何使用POI爲DOC文件時要解決的NoSuchMethodError
的任何代碼File someFile = new File("D:\\arz.doc");
InputStream inputStrm = new FileInputStream(someFile);
HWPFDocument wordDoc = new HWPFDocument(inputStrm);
System.out.println(wordDoc.getText());
或:
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("D:\\arz.doc"));
WordExtractor extractor = new WordExtractor(fs);
String wordText = extractor.getText();
,錯誤消息永遠是如下:
Exception in thread 「main」 java.lang.NoSuchMethodError:
org.apache.poi.poifs.filesystem.POIFSFileSystem.getRoot()Lorg/apache/poi/poifs/filesystem/DirectoryNode;
at org.apache.poi.hwpf.HWPFDocument.(HWPFDocument.java:186)
at DB_connect.dissertation_araalz.ParseWodDocFile.main(ParseWodDocFile.java:29)
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)
你能幫我解決這個問題嗎?
你可以嘗試移動你的文件在一個目錄中,看看它是否工作...更改您的代碼爲 File someFile = new File(「D:\\ somedir \\ arz.doc」); – jsshah 2012-07-11 00:26:53
你也確定...所有依賴的罐子在加載代碼時都在你的類路徑中... – jsshah 2012-07-11 00:27:23