commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "s[e]th & h[o]lth" <seth.ho...@gmail.com>
Subject [commons-net] Correcting a bug into org.apache.commons.net.ftp.FTPClient
Date Mon, 29 May 2006 15:48:31 GMT
Hello,

I meet a problem when using FTPClient.listFiles(String pathname) with a
space-char inside pathname.
I looked at the problem and i saw that many ftp clients implements this
function like :
CWD target_dir
LIST
instead of
LIST target_dir

So i replaced into [org.apache.commons.net.ftp.FTPClient]
    public FTPFile[] listFiles(String pathname)
    throws IOException
    {
        String key = null;
        FTPListParseEngine engine =
            initiateListParsing(key, pathname);
        return engine.getFiles();
    }

with

    public FTPFile[] listFiles(String pathname)
    throws IOException
    {
        String currentWorkingDirectory = this.printWorkingDirectory();
        this.cwd(pathname);
        pathname = null;
        String key = null;
        FTPListParseEngine engine =
            initiateListParsing(key, pathname);
        FTPFile[] result = engine.getFiles();
        this.cwd(currentWorkingDirectory);
        return result;
    }


And the result is better like this...

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message