com.ibm.di.protocols
Class FTP

java.lang.Object
  extended by com.ibm.di.protocols.FTP

public class FTP
extends java.lang.Object

This class implements the FTP functionality using a FTPClient object.


Constructor Summary
FTP()
          Constructor.
 
Method Summary
 boolean cd(java.lang.String path)
          Changes the current working directory on the FTP server.
 boolean close()
          Closes the connection to the FTP server.
 boolean connect(java.lang.String host)
          Connects to a given host on port 21.
 boolean connect(java.lang.String host, int port)
          Connects to a given host and port.
 java.lang.Object[] dir()
          Lists the contents of the current working directory.
 boolean get(java.lang.String remoteFile, java.lang.String localFile)
          Gets a remote file from the FTP server.
 java.lang.Exception getLastError()
          Returns the last exception occurred.
 java.lang.String getResponse()
          Returns the FTP server response to a previously sent command.
 boolean login(java.lang.String username, java.lang.String password)
          Logins the FTP client on the server with the given credentials.
 boolean put(java.lang.String localFile, java.lang.String remoteFile)
          Puts a remote file on the FTP server.
 boolean setAscii()
          Sets the transfer mode to ASCII.
 boolean setBinary()
          Sets the transfer mode to binary.
 boolean setLastErr(java.lang.Exception e)
          Sets the passed as parameter exception as the last exception of the FTP client so far.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTP

public FTP()
Constructor.

Method Detail

connect

public boolean connect(java.lang.String host)
Connects to a given host on port 21.

Parameters:
host - the host of the FTP server.
Returns:
true if no error occurs, otherwise false.

connect

public boolean connect(java.lang.String host,
                       int port)
Connects to a given host and port.

Parameters:
host - the host of the FTP server.
port - the port to connect to.
Returns:
true if no error occurs, otherwise false.

login

public boolean login(java.lang.String username,
                     java.lang.String password)
Logins the FTP client on the server with the given credentials.

Parameters:
username - the username used to login.
password - the password used to login.
Returns:
true if no error occurs, otherwise false.

close

public boolean close()
Closes the connection to the FTP server.

Returns:
true if no error occurs, otherwise false.

setBinary

public boolean setBinary()
Sets the transfer mode to binary.

Returns:
true if no error occurs, otherwise false.

setAscii

public boolean setAscii()
Sets the transfer mode to ASCII.

Returns:
true if no error occurs, otherwise false.

get

public boolean get(java.lang.String remoteFile,
                   java.lang.String localFile)
Gets a remote file from the FTP server.

Parameters:
remoteFile - a file to be copied.
localFile - the name of the file used when saving it on the local machine.
Returns:
true if no error occurs, otherwise false.

put

public boolean put(java.lang.String localFile,
                   java.lang.String remoteFile)
Puts a remote file on the FTP server.

Parameters:
remoteFile - the name used to save the file on the remote server.
localFile - the file to be sent to the FTP server.
Returns:
true if no error occurs, otherwise false.

cd

public boolean cd(java.lang.String path)
Changes the current working directory on the FTP server.

Parameters:
path - the new directory.
Returns:
true if no error occurs, otherwise false.

getResponse

public java.lang.String getResponse()
Returns the FTP server response to a previously sent command.

Returns:
the response returned to the FTP client.

dir

public java.lang.Object[] dir()
Lists the contents of the current working directory.

Returns:
the directory contents.

setLastErr

public boolean setLastErr(java.lang.Exception e)
Sets the passed as parameter exception as the last exception of the FTP client so far.

Parameters:
e - an exception.
Returns:
true if the given exception is null, otherwise false.

getLastError

public java.lang.Exception getLastError()
Returns the last exception occurred.

Returns:
the last occurred exception.