FileSystemNotFoundException: Provider "jndi" 未安装

FileSystemNotFoundException: Provider "jndi" not installed

我有这个 JSP 代码,我正在尝试 运行 从 .java 文件中读取所有行。我的目录树如下所示:

| WebContent

- | resources

- - | Foobar.java (The file I need to read it's lines)

- jspfile.jsp (Where I'm running the code) 

我的代码:

String.join("\n", (String[])Files.readAllLines(Paths.get(getServletContext().getResource("/resources/Foobar.java").toURI()), Charset.defaultCharset()).toArray());

每当我尝试 运行 时,我都会收到此错误:

java.nio.file.FileSystemNotFoundException: Provider "jndi" not installed
    java.nio.file.Paths.get(Unknown Source)

老实说,我不知道那是什么意思,我希望得到一些帮助

谢谢大家,我最终使用了这段代码:

public String readResource(String resource){
        try{
            BufferedReader in = new BufferedReader(new InputStreamReader(getServletContext().getResourceAsStream("/resources/"+resource)));
        String line = null;

        String data = "";
        while((line = in.readLine()) != null) {
            if(data!="")data+="\n";
            data+=line;
        }
        return data;
        }catch(IOException e){
            return "";
        }
    }

效果很好!