List of usage examples for org.apache.commons.net.ftp FTPClient getDefaultPort
public int getDefaultPort()
From source file:uk.ac.manchester.cs.datadesc.validator.utils.UrlReader.java
private FTPClient connect() throws VoidValidatorException { FTPClient ftp = new FTPClient(); //CB consider replacing with logger // suppress login details ftp.addProtocolCommandListener(new FtpListener(logger)); try {/*w ww .j a va 2s. c om*/ int reply; if (uri.getPort() > 0) { ftp.connect(uri.getHost(), uri.getPort()); } else { ftp.connect(uri.getHost()); } logger.info("Connected to " + uri.getHost() + " on port " + (uri.getPort() > 0 ? uri.getPort() : ftp.getDefaultPort())); // After connection attempt, you should check the reply code to verify // success. reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { ftp.disconnect(); throw new VoidValidatorException("Unable to connect to FTP server " + uri); } return ftp; } catch (IOException ex) { disconnect(ftp); throw new VoidValidatorException("Error to connect to FTP server " + uri, ex); } }