未处理的异常类型filenotfoundexception,编译问题

unhandled exception type filenotfoundexception, compilation problem

我正在尝试从磁盘读取文件,但遇到编译错误 在

 catch (Docx4JException | IOException e) {
                e.printStackTrace();
                log.error("Błąd Docx4J: ", e);
                throw e;
            }

未处理的异常类型 filenotfoundexception有什么想法吗?

Stream<Path> files = Files.list(Paths.get(genConfig.getDocxJiraReportDirectory()));

        files.forEach(file -> {

            final WordprocessingMLPackage wordMLPackage;

            try {
                wordMLPackage = fileGenerator.loadFile(genConfig.getDocxTemplateDirectory(),
                        params.getTemplateFileName());

                    FileInputStream fis = new FileInputStream(file.toString());
                    String data = IOUtils.toString(fis, "UTF-8");

                    System.out.println(data);

                    String dataFinal = XmlHelper.GenerateEanImage(data);

                    Docx4J.bind(wordMLPackage, dataFinal, Docx4J.FLAG_NONE);

                    String filePath = genConfig.getDocxReportDirectory() + "/" + file.getFileName();
                    Docx4J.save(wordMLPackage, new File(filePath), Docx4J.FLAG_NONE);
            } catch (Docx4JException | IOException e) {
                e.printStackTrace();
                log.error("Błąd Docx4J: ", e);
                throw e;
            }

        });

如果您真的想重新抛出异常,请将其包装在 RuntimeException 中。

    } catch (Docx4JException | IOException e) {
        e.printStackTrace();
        log.error("Błąd Docx4J: {}", e);
        throw new RuntimeException(e);
    }

顺便说一句,您在 log.error

中缺少一个 {}