I was trying to load a file in a webapp, and I was getting a FileNotFound
exception when I used FileInputStream
. However, using the same path, I wa
getResourceAsStream
is the right way to do it for web apps (as you already learned).
The reason is that reading from the file system cannot work if you package your web app in a WAR. This is the proper way to package a web app. It's portable that way, because you aren't dependent on an absolute file path or the location where your app server is installed.