FileInputStream 路径 拒绝访问
我只剩30分了,对不住大家了
package Java.se.lucene;
import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.apache.poi.hwpf.usermodel.Range;
public class wordToTxt {
//创建字符串缓冲区
StringBuffer stringBuffer=null;
//word文档路径
String path=new String("f:/lucene/words");
public String readWord()
{
try {
//创建存储word文档的对象
HWPFDocument doc = new HWPFDocument(new FileInputStream(path));
//用来获得word文档内容
Range range=doc.getRange();
//文档段落数目
int paragraphCount=range.numParagraphs();
//遍历段落读取数据
for(int i=0;i<paragraphCount;i++)
{
Paragraph pph=range.getParagraph(i);
stringBuffer.append(pph);
System.out.println(stringBuffer.toString());
}
} catch (
FileNotFoundException e) {
e.printStackTrace();
} catch (
IOException e) {
e.printStackTrace();
}
return stringBuffer.toString().trim();
}
public static void main(String[] args) {
new wordToTxt().readWord();
}
}
------解决方案--------------------
你这是
空指针错误啊。。。