直接运行main函数,控制台输出的中文乱码。在Andriod Studio中设置了编码方式也没有用,最终解决方法:
在工程目录下的build.gradle添加如下代码,然后重新运行一遍。
1.新版gradle
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
2.旧版gradle
tasks.withType(Compile){
options.encoding = "UTF-8"
}

直接运行main函数,控制台输出的中文乱码。在Andriod Studio中设置了编码方式也没有用,最终解决方法:
在工程目录下的build.gradle添加如下代码,然后重新运行一遍。
1.新版gradle
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
2.旧版gradle
tasks.withType(Compile){
options.encoding = "UTF-8"
}
本文标题:Android studio中java控制台输出中文乱码
本文链接:https://www.haomeiwen.com/subject/sdtarxtx.html
网友评论