看网上的很多解决中文乱码的问题,解决办法如下:
ftpClient.setControlEncoding("GBK");
String remoteName = "测试";
remoteName = new String(remoteName.getBytes("GBK"),"ISO-8859-1");
现在我分别用linux和windows搭载的ftp进行了测试,只要进行了remoteName = new String(remoteName.getBytes("GBK"),"ISO-8859-1")的转化,setControlEncoding,无论是GBK还是UTF8都能正确。
1.请教大家,setControlEncoding的作用到底是什么?
2.代码在执行时,编码到底是什么?操作系统是GBK,IDE是UTF-8