getResourceAsStream() vs FileInputStream

前端 未结 6 868
旧巷少年郎
旧巷少年郎 2020-11-21 06:09

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

6条回答
  •  青春惊慌失措
    2020-11-21 06:57

    FileInputStream will load a the file path you pass to the constructor as relative from the working directory of the Java process. Usually in a web container, this is something like the bin folder.

    getResourceAsStream() will load a file path relative from your application's classpath.

提交回复
热议问题