InputStream input = this.getClass().getResourceAsStream("test.properties");
与
InputStream input = this.getClass().getClassLoader().getResourceAsStream("test.properties");
的区别? test.properties在classpath目录下
InputStream input = this.getClass().getResourceAsStream("test.properties");
与
InputStream input = this.getClass().getClassLoader().getResourceAsStream("test.properties");
的区别? test.properties在classpath目录下
在使用Class.getResourceAsStream 时, 资源路径有两种方式, 一种以 / 开头,则这样的路径是指定绝对路径, 如果不以 / 开头, 则路径是相对与这个class所在的包的。
在使用ClassLoader.getResourceAsStream时, 路径直接使用相对于classpath的绝对路径。