classLoader.getResourceAsStream中文乱码

  一直用一个方法安然无恙,今天在新项目中忽然乱码了,原代码:优化

        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        
        InputStream is = null;
        is = classLoader.getResourceAsStream("config/constant.properties");
        if (is != null) 
        {
            try
            {
                props.load(is);
            }

 

 

优化后:spa

    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"));
            }
……
相关文章
相关标签/搜索