Sending UTF-8 Encoded File Name With FTPClient Class in Apache Commons


We can use FTPClient class in apache commons library to send UTF-8 encoded file names, such as Turkish, chinese, german etc.

ftpClient = new FTPClient();
String server ="";
int port = 21;
String user ="test";
String pass ="test";
ftpClient.setControlEncoding("UTF-8");//must be before connect() method

ftpClient.connect(server, port);
ftpClient.login(user, pass);
ftpClient.sendCommand("OPTS UTF8 ON");//we should send this command

© 2019 All rights reserved. Codesenior.COM