*/
public void connect(String host, String username, String password)
throws ProtocolException {
// server cannot be null
if (host == null) {
throw new ProtocolException("Tried to connect to server == NULL");
}
try {
ftp.connect(host);
ftp.enterLocalPassiveMode();
} catch (Exception e) {
throw new ProtocolException("Failed to connect to server : "
+ e.getMessage());
}
try {
// try logging in
if (!ftp.login(username, password)) {
throw new ProtocolException("Failed logging into host " + host
+ " as user " + username);
}
// set file type to binary
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
} catch (Exception e) {
// login failed
throw new ProtocolException(
"Exception thrown while logging into host " + host
+ " as user " + username);
}
}