|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ibm.di.protocols.FTPClient
public class FTPClient
This class represents a custom FTP client, that has the functionality to connect to a FTP server, to login, list contents, transfer data, etc.
| Field Summary | |
|---|---|
protected static java.lang.String |
COPYRIGHT
Copyright information. |
| Constructor Summary | |
|---|---|
FTPClient()
Default constructor. |
|
FTPClient(Log logger)
Constructor. |
|
| Method Summary | |
|---|---|
void |
checkComplete()
Checks whether the file transfer (when getting/putting a file on the FTP server) is over. |
void |
connect(java.lang.String host,
int port,
boolean useSSLonCommandChannel,
boolean useSSLonDataChannel)
Creates a connection to the given host and port. |
void |
cwd(java.lang.String cwd)
Changes the working directory with the one specified. |
void |
deleteFile(java.lang.String remoteFile)
Deletes a given file from the FTP server. |
java.lang.String[] |
dir()
Returns a long list of the contents of the current working directory on the FTP server. |
java.lang.String[] |
dir(java.lang.String path,
boolean longlisting)
Returns a string array with the contents of the given path. |
void |
disconnect()
Disconnects the client from the FTP server. |
boolean |
getDebug()
Gets the debug level used. |
java.net.Socket |
getFile(java.lang.String remoteFile,
boolean binary)
Retrieves the specified file from the FTP server. |
void |
getFile(java.lang.String remoteFile,
java.lang.String localFile,
boolean binary)
Retrieves the specified file from the FTP server. |
java.lang.String |
getResponse()
Retrieves the server response to a previously sent by the client command. |
boolean |
getUsePassive()
Returns true if we should try to use passive mode. |
java.lang.String[] |
list()
Returns a short list of the contents of the current working directory on the FTP server. |
java.net.Socket |
list(java.lang.String path,
boolean longlisting)
Lists the contents of a given path on the FTP server. |
void |
login(java.lang.String user,
java.lang.String password)
Logs to the FTP server using the given credentials. |
java.net.Socket |
putFile(java.lang.String remoteFile,
boolean binary)
Sends a local file to the server. |
void |
putFile(java.lang.String localPath,
java.lang.String remoteFile,
boolean binary)
Sends a local file to the server. |
java.lang.String |
pwd()
Get the current remote working directory. |
void |
rename(java.lang.String from,
java.lang.String to)
Renames a file or directory on the FTP server. |
java.lang.String |
sendCommand(java.lang.String cmd)
Sends the given command through the command channel. |
void |
setDebug(boolean debug)
Sets the client in detailed logging mode. |
void |
setTimeout(int millis)
This method does nothing. |
void |
setTransferMode(boolean binary)
Sets the transfer mode according to the type of files to be transfered. |
void |
setupDataSocket()
Creates the data socket used for data transferring between the FTP client and server. |
void |
setUsePassive(boolean value)
Sets this FTPClient to use passive mode (or not). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String COPYRIGHT
| Constructor Detail |
|---|
public FTPClient()
public FTPClient(Log logger)
logger - a Log object used for logging debug messages.| Method Detail |
|---|
public void setTimeout(int millis)
millis - the timeout to be set in milliseconds.public void setDebug(boolean debug)
debug - whether to log in details or not.public boolean getDebug()
public void connect(java.lang.String host,
int port,
boolean useSSLonCommandChannel,
boolean useSSLonDataChannel)
throws java.lang.Exception
host - the host to connect to.port - the port to connect to.useSSLonCommandChannel - whether to use SSL on the command channel.useSSLonDataChannel - whether to use SSL on the data channel.
java.lang.Exception - if there is a problem during the connection establishment.public void disconnect()
public void login(java.lang.String user,
java.lang.String password)
throws java.lang.Exception
user - the username to be used.password - the password to be used.
java.lang.Exception - if the logging process is unsuccessful.
public void cwd(java.lang.String cwd)
throws java.lang.Exception
cwd - the new working directory.
java.lang.Exception - if the process fails.
public void setupDataSocket()
throws java.lang.Exception
java.lang.Exception - if the operation fails.
public java.net.Socket getFile(java.lang.String remoteFile,
boolean binary)
throws java.lang.Exception
remoteFile - the file to be copied.binary - the type of the file (ASCII text or binary data). This
determines the transfer mode used by the client.
java.lang.Exception - if the transfer fails.
public void getFile(java.lang.String remoteFile,
java.lang.String localFile,
boolean binary)
throws java.lang.Exception
remoteFile - the file to be copied.localFile - the local file in which the contents of the remote to be
transfered.binary - the type of the file (ASCII text or binary data). This
determines the transfer mode used by the client.
java.lang.Exception - if the transfer fails.
public java.net.Socket putFile(java.lang.String remoteFile,
boolean binary)
throws java.lang.Exception
remoteFile - the file to be put on the server.binary - the type of the file (ASCII text or binary data). This
determines the transfer mode used by the client.
java.lang.Exception - if the operation fails.
public void putFile(java.lang.String localPath,
java.lang.String remoteFile,
boolean binary)
throws java.lang.Exception
localPath - the location of the transfered file on the FTP client machine.remoteFile - the file to be put on the server.binary - the type of the file (ASCII text or binary data). This
determines the transfer mode used by the client.
java.lang.Exception - if the operation fails.
public void setTransferMode(boolean binary)
throws java.lang.Exception
binary - if true the files will be sent as binary data, otherwise they
will be sent as ASCII text.
java.lang.Exception - if the operation failed and the server did not return a OK
code.
public void deleteFile(java.lang.String remoteFile)
throws java.lang.Exception
remoteFile - the file to be deleted.
java.lang.Exception - if the operation fails.
public void rename(java.lang.String from,
java.lang.String to)
throws java.lang.Exception
from - name of file or directory to rename.to - intended name.
java.lang.Exception - if the operation fails.
public java.lang.String pwd()
throws java.lang.Exception
java.lang.Exception - if the request fails.
public java.lang.String sendCommand(java.lang.String cmd)
throws java.lang.Exception
cmd - the command sent to the FTP server.
java.lang.Exception - if the operation fails.
public java.lang.String[] dir()
throws java.lang.Exception
java.lang.Exception
public java.lang.String[] list()
throws java.lang.Exception
java.lang.Exception
public java.lang.String[] dir(java.lang.String path,
boolean longlisting)
throws java.lang.Exception
path - the path which contents will be listed.longlisting - whether the list will be long or short.
java.lang.Exception
public void checkComplete()
throws java.lang.Exception
java.lang.Exception - if the operation fails.
public java.net.Socket list(java.lang.String path,
boolean longlisting)
throws java.lang.Exception
path - the path which contents must be shown.longlisting - determines whether the list should be short or long.
java.lang.Exception - if the operation fails.
public java.lang.String getResponse()
throws java.lang.Exception
java.lang.Exception - if the operation fails.public void setUsePassive(boolean value)
value - If true, try to use passive mode before falling back to the
old PORT mode. If false, never use passive mode.public boolean getUsePassive()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||