Java FTP could not get the file list and the result was only one dot (. )

use commons-net-3.6.jar for FTP connection,

The

connection is successful, also switch to the target directory, and then print it through ftp.listFiles (); with a length of only 1 strong getName (), but it is .

accessed through the browser, there are many files in the directory. However, using java FTP connection, you cannot get the file name

if (changeDirector(parseFTPReq())) {
    ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
    FTPFile[] ftpFiles = ftp.listFiles();
    for (int i = 0; i < ftpFiles.length; iPP) {
        String fileName = ftpFiles[i].getName();
        System.out.println(fileName);
    }
}

in addition, the access to the page is very slow, does it have anything to do with the network speed?

Mar.31,2021

found the reason. The FTP server is built under the Linux system. And. Two files, the subsequent logical judgment caused the exception, but no exception was thrown. I handled the exception myself.

Menu