用的是APACHE的FTPCLIENT, 但文件名中如果有中文, 传到服务器上就乱码了,
尝试过ftpClient.setControlEncoding("gb2312"); “UTF-8”,"GBK"
都不行, 弄了一半天, 不知道有什么办法吗
public boolean upload(String path, String fileName, InputStream inputStream) throws IOException {
boolean flag = false;
try {
ftpClient.setControlEncoding("gb2312");
FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
conf.setServerLanguageCode("en");
ftpClient.cwd(remotePath);
alertWorkingDirectory(path);
flag = ftpClient.storeFile(new String(fileName.getBytes("utf-8"), "gb2312"), inputStream);
if (flag) {
System.out.println(" upload success !!! ");
}
// ftpClient.sendCommand("chmod 777 " +fileName);
} catch (IOException e) {
logger.severe("not upload !!! " +e.getMessage());
throw new IOException(e);
}
return flag;
}
------解决方案--------------------------------------------------------
在客户端转码试试