项目场景:
使用FTP下载文件,FTP目录包含中文问题描述:
ftpPath = "/ftpPath/1/ftp目录";
FTPClient ftpClient = new FTPClient();
boolean b = ftpClient.changeWorkingDirectory(ftpPath);
log.info("b={}",b);
# 输出结果b=falss
原因分析:
FTP目录ftpPath中包含中文解决方案:
设置FtpClient中文编码
# function1:
ftpClient.setControlEncoding("GBK")
# function2:
boolean b = ftpClient.changeWorkingDirectory(new String(ftpPath.getBytes(), FTP .DEFAULT_CONTROL_ENCODING));