Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.3k views
in Java FTP by (220 points)
Hi all,

im currently using the latest edtftpj-1.5.5 version, and i found a bug while getting the path of a file from the server...
well, to explain the case, i'll have to say the scenario, which goes like this:

1st i defined an absolute path for the folder that i want to connect to on the remote server.
then i used the command:
            FTPFiles[] ftpFiles = ftp.dirDetails(remoteFolderPath);

i wanted to get a list of the files in that folder for processing and filtering it, to get in the end a list with only the needed files to get.
after processing the list, i used a "for" statement for getting that list of files from the server, in this way:
            for (int i=0 ; i<ftpFiles.length ; ++i){
                ftp.get( localHostPath + File.separator + ftpFiles[i].getName(),
                            ftpFiles[i].getPath() + "/" + ftpFiles[i].getName());
            }

but it returned out with an exception of not being able to open the file at server.
When i checked out the returned path from the getPath() function, i found that the function is giving me back the path of the home directory in the server concatenated with File.seperator and the "remoteFolderPath" value that i passed to the dirDetails function.

i think supplying an absolute path to the function should be taken under consideration to be modified, and also, when i checked out the source of the function, i found that it was using "File.seperator" to concat the paths together, which i find wrong, because in my case, i ran the code from my local machine OS (windows XP) while the remote server OS im connecting to was Linux RedHat, each of them has a different folder seperator type, and will generate an error when trying to use the windows seperator "/" in a Linux environment. Maybe you should consider using "\" as a seperator in all cases since it works on all OS platforms as far as i know, or use a seperator depending on the remote machine OS, not the local machine where im running the code.

btw, this problem have a workaround by changing the current working directory on the server 1st, using chdir(remoteFolderPath), then getting the folder list of files using dirDetails(""). Everythin will be correct then.

1 Answer

0 votes
by (162k points)
Hi Steve

Thanks for the feedback, I think you are right. We'll change the code to use '/' instead of File.separator.

Categories

...