方案一:
文件目录如下:
配置文件:firehosetos3sample.properties在src目录下面第一层,与包是一层的
在Getpath_ClassLoader.java类中:
System.out.println(Getpath_ClassLoader.class.getResource("/firehosetos3sample.properties"));
Getpath_ClassLoader为该类类名,将其替换为src下任一类名也可(可以是不同包)
运行,结果如下:
方案二:
获取该类同级目录下的resource目录:
Thread.currentThread().getContextClassLoader().getResource("final-model").toURI().getPath();
代码目录结构:
其中,代码java与resource同级。
而在编译之后的class文件目录如下:
that's all