|
|||||||||||
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 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(String host,
int port,
boolean useSSLonCommandChannel,
boolean useSSLonDataChannel)
Creates a connection to the given host and port. |
void |
cwd(String cwd)
Changes the working directory with the one specified. |
void |
deleteFile(String remoteFile)
Deletes a given file from the FTP server. |
String[] |
dir()
Returns a long list of the contents of the current working directory on the FTP server. |
String[] |
dir(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. |
Socket |
getFile(String remoteFile,
boolean binary)
Retrieves the specified file from the FTP server. |
void |
getFile(String remoteFile,
String localFile,
boolean binary)
Retrieves the specified file from the FTP server. |
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. |
String[] |
list()
Returns a short list of the contents of the current working directory on the FTP server. |
Socket |
list(String path,
boolean longlisting)
Lists the contents of a given path on the FTP server. |
void |
login(String user,
String password)
Logs to the FTP server using the given credentials. |
Socket |
putFile(String remoteFile,
boolean binary)
Sends a local file to the server. |
void |
putFile(String localPath,
String remoteFile,
boolean binary)
Sends a local file to the server. |
String |
pwd()
Get the current remote working directory. |
void |
rename(String from,
String to)
Renames a file or directory on the FTP server. |
String |
sendCommand(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 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(String host, int port, boolean useSSLonCommandChannel, boolean useSSLonDataChannel) throws 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.
Exception
- if there is a problem during the connection establishment.public void disconnect()
public void login(String user, String password) throws Exception
user
- the username to be used.password
- the password to be used.
Exception
- if the logging process is unsuccessful.public void cwd(String cwd) throws Exception
cwd
- the new working directory.
Exception
- if the process fails.public void setupDataSocket() throws Exception
Exception
- if the operation fails.public Socket getFile(String remoteFile, boolean binary) throws 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.
Exception
- if the transfer fails.public void getFile(String remoteFile, String localFile, boolean binary) throws 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.
Exception
- if the transfer fails.public Socket putFile(String remoteFile, boolean binary) throws 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.
Exception
- if the operation fails.public void putFile(String localPath, String remoteFile, boolean binary) throws 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.
Exception
- if the operation fails.public void setTransferMode(boolean binary) throws Exception
binary
- if true the files will be sent as binary data, otherwise they
will be sent as ASCII text.
Exception
- if the operation failed and the server did not return a OK
code.public void deleteFile(String remoteFile) throws Exception
remoteFile
- the file to be deleted.
Exception
- if the operation fails.public void rename(String from, String to) throws Exception
from
- name of file or directory to rename.to
- intended name.
Exception
- if the operation fails.public String pwd() throws Exception
Exception
- if the request fails.public String sendCommand(String cmd) throws Exception
cmd
- the command sent to the FTP server.
Exception
- if the operation fails.public String[] dir() throws Exception
Exception
public String[] list() throws Exception
Exception
public String[] dir(String path, boolean longlisting) throws Exception
path
- the path which contents will be listed.longlisting
- whether the list will be long or short.
Exception
public void checkComplete() throws Exception
Exception
- if the operation fails.public Socket list(String path, boolean longlisting) throws Exception
path
- the path which contents must be shown.longlisting
- determines whether the list should be short or long.
Exception
- if the operation fails.public String getResponse() throws Exception
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 |