首页 > 解决方案 > 获取 java.nio.file.NoSuchFileException:

问题描述

我在 /common 下有一个名为 upgradePagePromoCodeState.json 的文件。

当我使用这样的文件路径时:

/work/xxx/app/src/main/webapp.war/common/upgradePagePromoCodeState.json

它在本地执行,但不是分阶段执行。我怎样才能提供在阶段和本地工作的路径?

String filePath = "/work/xxx/app/src/main/webapp.war/common/upgradePagePromoCodeState.json";
try {
    String jsonText = new String(Files.readAllBytes(Paths.get(filePath)));
} catch (IOException e) {
    logger.log(Level.SEVERE, "Error while pasing a file", e);
}

标签: javafile-io

解决方案


推荐阅读