Java FileSystemNotFoundException:提供程序;jndi“;未安装

Java FileSystemNotFoundException:提供程序;jndi“;未安装,java,file,jsp,jndi,Java,File,Jsp,Jndi,我有这个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(getServletCon

我有这个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 "";
        }
    }

它工作得很好

资源不是文件,资源的URL也不是文件名。您可以以流的形式获取资源。这样做。