阅读更多
package com.purang.pdf;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.textmining.text.extraction.WordExtractor;
public class Word {
public static void main(String args[]){
try{
//读取 用 DataInputStream
// DataInputStream fin=new DataInputStream(new FileInputStream( "D:/word/JAVA读取word文件.doc "));
//写入用 DataOutputStream
//读取
final int BUFFER_SIZE = 16 * 1024 ;
FileInputStream in = new FileInputStream("D:/word/JAVA读取word文件.doc");
WordExtractor extractor = new WordExtractor();
String str = extractor.extractText(in);
//写入
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("D:/word/d.txt "), BUFFER_SIZE);
out.write(str.getBytes("utf-8"));
out.close();
System.out.println("读写完成");
}
catch(Exception e){
}
}
}