I have a Java web app posted in the Tomcat and I need to read a special file in the webpage's directory.
This attempts to read:
string path = "c: \\ program files \\ Apache software foundation \\ sharing \\ webapps \ Server \\ config \\ myfile.csv "; File file = new file (path); If (file.exists ()) // read the file ... file.exists () returns incorrectly, but in Windows I Can I navigate explorer? Is this a problem with any kind of permission? Any clues as to what could be wrong? I'm losing a lot
The best way to achieve this is to achieve what you are trying to achieve. One thing is very brittle, it is very brittle.
You should use the ServletContext.getResourceAsStream ("/ config / myfile.csv")
No comments:
Post a Comment