Issue with org.apache.commons.net.ftp.FTPClient listFiles()

前端 未结 3 498
迷失自我
迷失自我 2020-12-19 07:01

The listFiles() method of org.apache.commons.net.ftp.FTPClient works fine with Filezilla server on 127.0.0.1 but returns null on the r

3条回答
  •  没有蜡笔的小新
    2020-12-19 07:36

    Each FTP server has a different file list layout (yes, it's not part of the FTP standard, it's dumb), and so you have to use the correct FTPFileEntryParser, either by specifying it manually, or allowing CommonsFTP to auto-detect it.

    Auto-detection usually works fine, but sometimes it doesn't, and you have to specify it explicitly, e.g.

    FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
    
    FTPClient client = FTPClient();
    client.configure(conf);
    

    This explicitly sets the expected FTP server type to UNIX. Try the various types, see how it goes. I tried finding out myself, but ftp.belnet.be is refusing my connections :(

提交回复
热议问题