Class.getResourceAsStream(String path) :
1 在類的同級目錄下path直接寫資源名
2 在當前類的目錄的子目錄下path寫當前類的相對路徑
Class.getClassLoader.getResourceAsStream(String path):
既不在當前類的同級目錄下,也不在當前類的子目錄下,使用這種方法,path默認是以ClassPath根目錄起始
Eclipse中文件在src/main/resources中時直接寫文件名即可
ServletContext. getResourceAsStream(String path):
獲取web項目下的資源,path默認是以WEBAPP的根目錄起始