在setDomianEnv.sh中添加环境变量-Dfile.encoding=GBK 问题解决。
其原因在于String.getBytes()时实际调用StringCoding.encode(value, offset, count)方法,其中使用默认编码Charset.defaultCharset().name()。defaultCharset从环境变量file.encoding中取值。
故设置环境变量-Dfile.encoding=GBK 改变默认编码
在setDomianEnv.sh中添加环境变量-Dfile.encoding=GBK 问题解决。
其原因在于String.getBytes()时实际调用StringCoding.encode(value, offset, count)方法,其中使用默认编码Charset.defaultCharset().name()。defaultCharset从环境变量file.encoding中取值。
故设置环境变量-Dfile.encoding=GBK 改变默认编码