|
@@ -338,24 +338,23 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
try{
|
|
|
String path = file.getOriginalFilename();
|
|
|
if (path.endsWith(".doc")) {
|
|
|
- InputStream is = file.getInputStream();
|
|
|
-
|
|
|
+ throw new CustomException("不支持doc格式");
|
|
|
+ /*InputStream is = file.getInputStream();
|
|
|
WordExtractor wordExtractor = new WordExtractor(is);
|
|
|
buffer = wordExtractor.getText();
|
|
|
- wordExtractor.close();
|
|
|
- System.out.println("CC");
|
|
|
- System.out.println(buffer);
|
|
|
+ wordExtractor.close();*/
|
|
|
} else if (path.endsWith("docx")) {
|
|
|
- OPCPackage opcPackage = POIXMLDocument.openPackage(path);
|
|
|
- POIXMLTextExtractor extractor = new XWPFWordExtractor(opcPackage);
|
|
|
+ InputStream is = file.getInputStream();
|
|
|
+ XWPFDocument doc = new XWPFDocument(is);
|
|
|
+ XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
|
|
buffer = extractor.getText();
|
|
|
extractor.close();
|
|
|
- System.out.println(buffer);
|
|
|
+
|
|
|
} else {
|
|
|
- System.out.println("此文件不是word文件!");
|
|
|
+ throw new CustomException("请导入word文件!");
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
-
|
|
|
+ System.out.println("此文件不是word文件!A"+e.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|