Listening for events |
For an object to listen for events published by the Fxp class the following steps are required:
Example
import com.jscape.inet.ftp.*;
public class FxpExample implements FxpListener {
/** * Create new FxpExample instance */ public FxpExample() { // create new Fxp instance Fxp fxp = new Fxp();
// subscribe to listener fxp.addFxpListener(this);
// write additional code here to do transfer }
/** * Invoked when FXP transfer starts for a file. * * @param ev a <code>FxpStartEvent</code> * @see FxpStartEvent */ public void fxpStart(FxpStartEvent ev) { Ftp source =(Ftp)ev.getSource(); Ftp dest = (Ftp)ev.getDestination(); System.out.println("Starting transfer of " + ev.getFilename() + " from " + source.getHostname() + " to " + dest.getHostname()); }
/** * Invoked when FXP transfer ends for a file. * * @param ev a <code>FxpEndEvent</code> * @see FxpEndEvent */ public void fxpEnd(FxpEndEvent ev) { Ftp source =(Ftp)ev.getSource(); Ftp dest = (Ftp)ev.getDestination(); System.out.println("Ending transfer of " + ev.getFilename() + " from " + source.getHostname() + " to " + dest.getHostname()); }
/** * Invoked when FXP transfer fails for a file. * * @param ev a <code>FxpFailedEvent</code> * @see FxpFailedEvent */ public void fxpFailed(FxpFailedEvent ev) { Ftp source =(Ftp)ev.getSource(); Ftp dest = (Ftp)ev.getDestination(); System.out.println("Failed transfer of " + ev.getFilename() + " from " + source.getHostname() + " to " + dest.getHostname()); } }
See also
|