ftp
Interface FtpObserver
- public interface FtpObserver
The class that implement this interface have the ability to monitor the progress
of upload and download files in the FtpBean.
You can pass the object which implement this interface to some put/get methods
of the FtpBean object. So that when there are any bytes read from the server,
the byteRead(int) method of the object you passed is invoked. And the byteWrite(int)
method is invoked when any bytes is written to the server side.
A sample code is like this:
// Begin, this class implements the FtpObserver interface
class Sample implements FtpObserver
{
// Skip constructors and many things for simple
public void download()
{
try
{
// Pass this object which implements FtpObserver interface to the method
ftpbean.getBinaryFile("remotefile", "localfile", this);
} catch(Exception e)
{
System.out.println("Exception!!!");
}
}
public void byteRead(int bytes)
{
System.out.println(bytes + " new bytes are read.");
}
public void byteWrite(int bytes)
{
System.out.println(bytes + " new bytes are written to server.");
}
}
Method Summary |
void |
byteRead(int bytes)
This method is called every time new bytes are read in downloading process. |
void |
byteWrite(int bytes)
This method is called every time new bytes is written to the ftp server in uploading process. |
byteRead
public void byteRead(int bytes)
- This method is called every time new bytes are read in downloading process.
- Parameters:
bytes
- The number of new bytes read from the server.
byteWrite
public void byteWrite(int bytes)
- This method is called every time new bytes is written to the ftp server in uploading process.
- Parameters:
bytes
- The number of new bytes write to the server.