Androidstudio解决乱码问题

前天同事给一个输出配置文件的工具.导入项目后是这样子的!

google一番后得解.确保这几个都是utf-8.

1.

2.在项目build.gradle 中dependencied下添加

tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
}

3.输入的文件制定编码类型

file.createNewFile();
FileOutputStream fos=new FileOutputStream(filePath);
OutputStreamWriter writer = new OutputStreamWriter(fos, Charset.forName("utf-8"));
writer.write(content);
writer.close();

猜你喜欢

转载自blog.csdn.net/qq_39792615/article/details/107163512