I am using the FTP library provided by Apache (commons-net). I want to check if a file exists on an FTP server, so I use the method listFiles FTPClient:
ftpClient.listFiles(remoteFileDir + "\\" + fileName);
The current directory is the root directory of the FTP server. So the value remoteFileDiris the path to this root directory.
My question is about merging between the remote directory and the file name. What is the right way to do this? For a local file, I would do:
File file = new File(remoteFileDir,fileName);
but it doesn’t work here, because when I call file.getAbsolutePath(), I get the absolute path to the file in the local current directory, which I don’t want. Also, I think the merge was done according to my local environment.
PS: I looked at How are paths on remote machines determined? but it doesn’t help me.
thank
source
share