String sll = path;
            //获取字符后四位
            if(sll.substring(sll.length()-4, sll.length()).equals(".xls")) {
                // 获取Excel文件对象
                HSSFWorkbook workBook = new HSSFWorkbook(stream);
            }else if(sll.substring(sll.length()-4, sll.length()).equals(".xlsx")) {
                //xlsx
                HSSFWorkbook workBook = new HSSFWorkbook(stream);
            }else if(sll.substring(sll.length()-5, sll.length()).equals(".docx")) {
                //用来读取docx文件
                XWPFDocument doc = new XWPFDocument(stream);
            }else if(sll.substring(sll.length()-4, sll.length()).equals(".doc")){
                //doc
                 HWPFDocument doc = new HWPFDocument(stream);
            }else if(sll.substring(sll.length()-4, sll.length()).equals(".pdf")) {
                //pdf
                 PDDocument pd = PDDocument.load(stream);
            }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-12-28
  • 2021-05-12
  • 2021-12-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-04
  • 2022-01-15
  • 2021-11-10
  • 2021-10-16
  • 2021-12-27
相关资源
相似解决方案