FileWriter指定编码格式

FileWriter 默认是用(ISO-8859-1 or US-ASCII)西方编码的,总之不是UTF-8的,而FileWriter类有getEncoding方法,却没有setEncoding的方法,如下的写法可以使正确输出UTF-8的文件:

            Writer newFile;
            try {
                newFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(entry.getKey().substring(0, entry.getKey().length()-4) + ".java"),"UTF-8"));

 

相关文章:

  • 2021-07-07
  • 2022-03-10
  • 2021-10-27
  • 2021-07-28
  • 2022-12-23
  • 2022-01-01
  • 2022-02-09
猜你喜欢
  • 2021-04-10
  • 2022-12-23
  • 2021-05-15
  • 2021-11-22
  • 2021-08-09
  • 2021-05-24
相关资源
相似解决方案