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

我有一个简单的方法来检查路径是否是包含某些文件的目录。尽管该文件夹中有许多文件,但检查失败。


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/templates

isDirectory false 

我应该如何设置路径以便检查不会失败?


缥缈止盈
浏览 183回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java