解決reportNG中文亂碼(轉:http://www.it610.com/article/3626590.htm)

1.下載reportng源碼
     git clone  https://github.com/dwdyer/reportng.git
2.修改AbstractReporter.java
     package org.uncommons.reportng;
     ...
     import java.io.OutputStream;
     ...
     protected void generateFile(File file,
                                String templateName,
                                VelocityContext context) throws Exception
    {
        //Writer writer = new BufferedWriter(new FileWriter(file));
        //encoding to utf-8
        OutputStream out = new FileOutputStream(file);
        Writer writer = new BufferedWriter(new OutputStreamWriter(out,"utf-8"));
        try
        {
            Velocity.mergeTemplate(classpathPrefix + templateName,
                                   ENCODING,
                                   context,
                                   writer);
            writer.flush();
        }
        finally
        {
            writer.close();
        }
    }
3.編譯源碼
     cd reportng
     ant
 
PS:ant環境配置
1.下載ant源碼包
      http://ant.apache.org/bindownload.cgi
2.解壓到安裝位置
     unzip to D:\apache-ant-1.9.6
3.修改環境變量
     set ANT_HOME      D:\apache-ant-1.9.6
     set Path                  %ANT_HOME%\bin
4.驗證ant
     cmd:ant -version

解決reportNG中文亂碼java

相關文章
相關標籤/搜索