@GetMapping("/differences") public AjaxResult differences() { Version ver=new Version(); File file1 = new File("D:\\Documents\\3.doc"); File file2 = new File("D:\\Documents\\4.doc"); try { FileInputStream fis1 = new FileInputStream(file1); FileInputStream fis2 = new FileInputStream(file2); WordExtractor wordExtractor1 = new WordExtractor(fis1); WordExtractor wordExtractor2 = new WordExtractor(fis2); System.out.println("【1、 使用getText()方法提取的Word文件的内容如下所示:】"); System.out.println(wordExtractor1.getText()); System.out.println("【2、 使用getText()方法提取的Word文件的内容如下所示:】"); System.out.println(wordExtractor2.getText()); ver.setBy1(wordExtractor1.getText()); ver.setBy2(wordExtractor2.getText()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return AjaxResult.success(ver); }
pom.xml引入依赖:
<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <version>3.17</version> </dependency>