java - FileSystemNotFoundException: Provider "jndi" not installed -
i have jsp code i'm trying run read lines .java file. directory tree looks this:
| webcontent - | resources - - | foobar.java (the file need read it's lines) - jspfile.jsp (where i'm running code)
my code:
string.join("\n", (string[])files.readalllines(paths.get(getservletcontext().getresource("/resources/foobar.java").touri()), charset.defaultcharset()).toarray());
whenever try run error:
java.nio.file.filesystemnotfoundexception: provider "jndi" not installed java.nio.file.paths.get(unknown source)
i have no idea means , i'd love help
thanks all, wound using code:
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 ""; } }
it works great!
Comments
Post a Comment