commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thorsten.scherler....@juntadeandalucia.es>
Subject Re: Commons-net FTP: how to check if file exists
Date Tue, 06 Nov 2007 10:08:52 GMT
On Fri, 2007-11-02 at 09:10 +0200, Denis Bessmertniy wrote:
> Hi,
> 
> How is the best to check with FtpClient that file exists on FTP.

String path = "/" + dir ;
client.changeWorkingDirectory(path);
String reply = client.getReplyString().substring(0, 3);
if (reply.equals("250")) {
      LOG
          .debug("We will now process the path since the server response
code was 250.\n");
    } else
      LOG
          .debug("Ignoring this path, since the server did not return
the 250 success code!\n"
              + "Most likely because the path does not exist.\n");
  }

HTH

salu2
> 
> 
> -
> Denis
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message