public static void main(String[] args) throws Exception {
//resource目录下
String path = "code.properties";
EncodedResource encodedResource = new EncodedResource(new ClassPathResource(path),
Charsets.UTF_8);
Properties properties = PropertiesLoaderUtils.loadProperties(encodedResource);
String property = properties.getProperty("audit.ios_cvs_http_protocol.name");
System.out.println(property);
}
读取配置文件并中文输出
最新推荐文章于 2023-06-15 06:32:31 发布
本文介绍了一个使用Java读取资源目录下code.properties文件的例子。通过EncodedResource结合ClassPathResource定位文件,并采用Charsets.UTF_8指定字符集加载属性文件。最终通过PropertiesLoaderUtils加载属性并打印指定键对应的值。
1万+

被折叠的 条评论
为什么被折叠?



