getResourceAsStream() vs FileInputStream

前端 未结 6 851
旧巷少年郎
旧巷少年郎 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:58

    classname.getResourceAsStream() loads a file via the classloader of classname. If the class came from a jar file, that is where the resource will be loaded from.

    FileInputStream is used to read a file from the filesystem.

提交回复
热议问题