I have now looked a little bit into the source code of the FTPClient class...
The problem is:
The FTP-Server I try to connect to does not know about the commands SIZE and MDTM,
so RETR is called.
Before sending RETR, a PORT command is also sent which tells the FTP server to which
port it should send the data. Since we do not want to get the data, the port is closed
immeditately after creating the ServerSocket so in theory we should not get stressed
by getting all the file data.
Excerpt from FTPClient.exists()
...
// ok, now try RETR since nothing else is supported
ServerSocket sock = new ServerSocket(0);
short port = (short)sock.getLocalPort();
sock.close();
control.sendPORTCommand(port);
// send the retrieve command
lastReply = control.sendCommand("RETR " + remoteFile);
char ch = lastReply.getReplyCode().charAt(0);
...
But I think here is the problem - I guess the server sends the response not until
it has established a connection for the data. But this must fail since no one listens
on this port at the client.
So the FTPClient waits and waits for a response that never comes.
I think the only solution is the one I already mentioned - read the directory names
and check whether the wanted file is in the list.
If you know a better solution please let me know!
Regards,
Reinhard