1、读取yml
InputStream ymlStream = this.getClass().getResourceAsStream("/excleTemplate/test.yml"); // 以/开头表示从根路径下开始找,这点需要注意,不要忘记了!
Yaml yaml = new Yaml();//org.yaml.snakeyaml.Yaml
JSONObject j = yaml.loadAs(ymlStream , JSONObject.class);
2、读取properties
InputStream psStream = this.getClass().getResourceAsStream("/excleTemplate/test.properties");
Properties ps = new Properties();//java.util.Properties
ps.load(psStream );Map<String, String> map = ps.forEach((k, v) -> map.put((String)k, (String)v));