Problem Description:
An FTP server was built on the server with FileZilla server, and the FTP in the Apache.commons.net package was used in the native program. FtpClient class upload download file, file upload download the filename after the display of the wood is a problem, that is, in the program using ListNames (), or listfiles () to get the file name, the Chinese filename will be garbled, like "???. PNG "like this.
Workaround:
Search on the Internet, said the code does not match, to get the file name, with Name=new String (name.getbytes ("UTF-8"), "GBK"); Such a way, of course, is not necessarily the two encodings, the order is not always. But after trying it, it's useless.
Then finally found a clear explanation: http://lioncn.blog.51cto.com/1557898/432835; Because the server-side character set and the client character set do not match, FileZilla Server uses Utf-8 by default. And our operating system is generally Chinese, the default character set is GBK, so it is not. It is recommended to use a special version of FileZilla server or patching, the easiest way is to send a command to the FTP server "opts UTF8 off", everything OK.
Testing on the client is feasible, but what to do in the program, call FtpClient's DoCommand ("opts", "UTF8 off");