java - 获取 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);
}
解决方案
推荐阅读
- c# - 如何将 JSON 对象作为参数从 Postman 传递到 ASP.NET WEB API
- php - 为 Foreach() 提供的 Ajax 无效参数
- c# - 通过 Control 对象读取自定义控件属性的值
- javascript - Node.js Express - 在 json (res.json) 中发送数组
- javascript - 有没有一种简单的方法来自定义 JSON.stringify 如何格式化数组?
- python-3.x - 有没有办法使用try,除了传入keras自定义指标?
- ios - 拉动后滚动到屏幕顶部以在表格视图中刷新
- time - 服务器和客户端计时不同
- android - Android 在 doInBackground(..) 中启动嵌套 AsyncTask
- go - func main() 上的通道发送和接收