为了账号安全,请及时绑定邮箱和手机立即绑定

来自 abs 路径的文件未正确实例化

来自 abs 路径的文件未正确实例化

缥缈止盈 2021-09-03 14:39:02
我有一个简单的方法来检查路径是否是包含某些文件的目录。尽管该文件夹中有许多文件,但检查失败。public boolean check() throws FileNotFoundException {        LOG.info("getPath, prefix set to : {}", prefix);        File templatesFolder = new File(prefix);        if (!templatesFolder.isDirectory() || templatesFolder.list() == null || templatesFolder.list().length == 0) {            LOG.error("Templates cannot be found in absolute path {}", templatesFolder.getAbsolutePath());            LOG.error("templatesFolder.isDirectory() {}", templatesFolder.isDirectory());            return false;        }        return true;    }这是输出:prefix set to : file:///tmp/templates/Templates cannot be found in absolute path /home/oozen/workspace/pdfGenerator/file:/tmp/templatesisDirectory false 我应该如何设置路径以便检查不会失败?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 178 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信