下载相应的jar包(poi)
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.hwpf.extractor.WordExtractor;
public class InputStream1 {
public static void main(String[] args) throws IOException {
String text = "";
File file = new File("D:\\111.doc");
InputStream is = new FileInputStream(file);
WordExtractor word = new WordExtractor(is);
text = word.getText();
text = text.replaceAll("(\r\n|\r|\n|\n\r)", "<br/>");
text = text.replaceAll(" ", " ");
text = text.replaceAll("\t", "  ");
System.out.println(text);
}
}