Can't download files with Arabic name with Java FTP client

前端 未结 1 1718
一整个雨季
一整个雨季 2021-01-07 05:27

I have Java code that connects to an FTP server and downloads files. If the file name contains Arabic letters, then it always fails to download. But if it\'s English, it dow

相关标签:
1条回答
  • 2021-01-07 06:33

    You may need to use UTF-8 encoding. First thing to try is to call FTPClient.setAutodetectUTF8:

    ftpClient.setAutodetectUTF8(true);
    

    (call that before connecting)

    That should fix the problem your question is about.


    Once you resolve the file name issue, you will need to fix transfer mode issue. You are transferring binary files (PDF) in text mode.

    You need to use binary mode:

    ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
    
    0 讨论(0)
提交回复
热议问题