Class Ftp
java.lang.Object
|
+--Ftp
- public class Ftp
- extends java.lang.Object
This class supports the ability to transfer files via FTP.
Usage:
- The typical scenario for using this class is:
Ftp ftp = new Ftp();
ftp.connect(strServer, strUsername, strPassword);
ftp.putAsciiFile(strFilename, strContent);
ftp.disconnect();
Assumptions:
Effects:
- Transfers files via FTP.
Anticipated Changes:
- Add more FTP features. Currently, it supports only FTP PUT of ASCII
files.
Notes:
Implementation Notes:
Portability Issues:
- Since:
- 2.5.0
- Version:
- $Revision: 2 $
- Author:
- $Author: FStluka $
Inner Class Summary |
static class |
Ftp.FtpException
This exception is thrown when something goes wrong during the FTP
transfer. |
static class |
Ftp.Tester
Each class contains a Tester inner class with a main() for easier
unit testing. |
Constructor Summary |
Ftp()
Constructor. |
Method Summary |
void |
connect(java.lang.String strServer,
java.lang.String strUsername,
java.lang.String strPassword)
Connect to the FTP server and login. |
void |
disconnect()
Disconnect from the FTP server. |
void |
putAsciiFile(java.lang.String strFilename,
java.io.Reader readerContent)
PUT an ASCII file to the FTP server. |
void |
putAsciiFile(java.lang.String strFilename,
java.lang.String strContent)
PUT an ASCII file to the FTP server. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Ftp
public Ftp()
- Constructor.
- Parameters:
None.
- - Throws:
Exceptions
- None.
connect
public void connect(java.lang.String strServer,
java.lang.String strUsername,
java.lang.String strPassword)
throws Ftp.FtpException,
java.io.IOException
- Connect to the FTP server and login.
- Parameters:
strServer
- DNS name or IP address of FTP server.strUsername
- Username for logging in to server.strPassword
- Password for logging in to server.- Returns:
- None.
- Throws:
Ftp.FtpException
- When an FTP error, like login failure, occurs.java.io.IOException
- When an I/O error occurs.
disconnect
public void disconnect()
throws Ftp.FtpException,
java.io.IOException
- Disconnect from the FTP server.
- Returns:
- None.
- Throws:
Ftp.FtpException
- When an FTP error occurs.java.io.IOException
- When an I/O error occurs.
putAsciiFile
public void putAsciiFile(java.lang.String strFilename,
java.io.Reader readerContent)
throws Ftp.FtpException,
java.io.IOException
- PUT an ASCII file to the FTP server.
- Parameters:
strFilename
- Name of file to create on server.readerContent
- Reader containing content to write to the
file.- Returns:
- None.
- Throws:
Ftp.FtpException
- When an FTP error, like permission denied,
occurs.java.io.IOException
- When an I/O error occurs.
putAsciiFile
public void putAsciiFile(java.lang.String strFilename,
java.lang.String strContent)
throws Ftp.FtpException,
java.io.IOException
- PUT an ASCII file to the FTP server.
- Parameters:
strFilename
- Name of file to create on server.strContent
- String to write to the file.- Returns:
- None.
- Throws:
Ftp.FtpException
- When an FTP error, like permission denied,
occurs.java.io.IOException
- When an I/O error occurs.