// Connect
try {
ftpClient.connect(hostname, port);
} catch (Exception ex) {
throw new FileSystemException("Could not connect to the host", ex);
}
if(!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
disconnect();
throw new FileSystemException("The host refused the connection");
}
// Login
try {
if (!ftpClient.login(user, pass)) {
throw new FileSystemException("The user/pass combinaison is invalid on this host");
}
} catch (IOException ex) {
throw new FileSystemException("The host disconnected while logging in");
}
// Set up the connection
try {
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
} catch (IOException ex) {
throw new FileSystemException("Could not set up the connection with the host", ex);
}
}