标签:hellip stream context nbsp new thread reader utf-8 优化
一直用一个方法安然无恙,今天在新项目中突然乱码了,原代码:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream is = null; is = classLoader.getResourceAsStream("config/constant.properties"); if (is != null) { try { props.load(is); }
优化后:
static { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream is = null; is = classLoader.getResourceAsStream("config/constant.properties"); if (is != null) { try { props.load(new InputStreamReader(is,"UTF-8")); } ……
classLoader.getResourceAsStream中文乱码
标签:hellip stream context nbsp new thread reader utf-8 优化
原文地址:https://www.cnblogs.com/yanan7890/p/10077251.html