该文是java读取文件写入文件的应用,相关知识见上篇博文https://blog.csdn.net/nnnora/article/details/80734917
一个例子:读取word英文文档,统计单词频次并输出到excel
public FileOutputStream getwordsFrequency(MultipartFile file) {
FileOutputStream fos = null;
try {
//读取word文件
String path = "Shocking level of sexual harassment at music festivals.docx";
String buffer = "";
if (path.endsWith(".doc")) {
ClassPathResource classPathResource = new ClassPathResource(path);
WordExtractor wordExtractor = new WordExtractor(classPathResource.getInputStream());
buffer = wordExtractor.getText();
} else if (path.endsWith("docx")) {
ClassPathResource classPathResource = new ClassPathResource(path);
XWPFDocument xdoc = new XWPFDocument(classPathResource.getInputSt