I am using org.apache.commons.net package to receive files by FTP.
I want to list a specific directory inside ftp server but I have the following problem :
I can list directory with name like "abc"
but I can't list directory with name like "ab c d"
Here is the code that I am using :
files = ftp.listFiles("\\ab c d\\");
System.out.println("LENGHT : "+files.length);
for (int i=0;i<files.length;i++)
System.out.println(i+" TEST : "+files);
files.length ==0 when I use directory name like "ab c d"
I have used also files = ftp.listFiles("\"\\ab c d\\\"");
but without success.
Thanks a lot in advance.
If you were responsible for creating those directories, you should be ashamed - spaces in files/folders is silly and always results in more annoyance than any gains in aesthetics. Anyway...
Just a guerss - try escaping the path name, like this
There might be a way to escape it.
Or there might not.
If there is it probably depends on the server.
You should use a gui ftp client (console commands not graphic) and use trial and error to find one.
There are two basic patterns possible.
- Escape the entire expression
- Escape the spaces themselves.
Common escape chars would be