1、文件放在src(类的根路径)下
String path = Thread.currentTread().getContextClassLoader()
.getResource("xxx.properties").getpath();
2、资源绑定器
只能用来读取.properties 文件的路径,文件同样需要放在类路径下(src)
import java.util.ResourceBundle;
ResourceBundle bundle = ResourceBundle.getBundle("xxx");
String className = bundle.getString("className");