|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.enterprisedt.net.ftp.FileTransferClient
public class FileTransferClient
Easy to use FTP client that is thread safe and provides true FTP streams. This class is intended to replace FTPClient, which will eventually be deprecated.
| Field Summary | |
|---|---|
protected com.enterprisedt.net.ftp.internal.EventAggregator |
eventAggregator
|
protected EventListener |
listener
Event listeners |
protected com.enterprisedt.net.ftp.internal.ConnectionContext |
masterContext
Context for the client that is the starting point for all new tasks. |
| Constructor Summary | |
|---|---|
FileTransferClient()
Default constructor |
|
| Method Summary | |
|---|---|
void |
cancelAllTransfers()
Cancel current transfer if underway |
void |
changeDirectory(java.lang.String directoryName)
Change directory on the FTP server. |
void |
changeToParentDirectory()
Change to parent directory on the FTP server. |
protected void |
checkConnection(boolean shouldBeConnected)
Checks if the client has connected to the server and throws an exception if it hasn't. |
void |
connect()
Make a connection to the FTP server. |
void |
createDirectory(java.lang.String directoryName)
Create directory on the FTP server. |
void |
deleteDirectory(java.lang.String directoryName)
Delete directory on the FTP server. |
void |
deleteFile(java.lang.String remoteFileName)
Deletes a remote file. |
FTPFile[] |
directoryList()
List the current directory on the FTP server. |
FTPFile[] |
directoryList(java.lang.String directoryName)
List a directory on the FTP server. |
void |
directoryList(java.lang.String directoryName,
DirectoryListCallback lister)
List a directory on the FTP server. |
java.lang.String[] |
directoryNameList()
List the names of files and directories in the current directory on the FTP server. |
java.lang.String[] |
directoryNameList(java.lang.String directoryName,
boolean isLongListing)
List the names of files and directories of a directory on the FTP server. |
void |
disconnect()
Disconnect from the FTP server. |
void |
disconnect(boolean immediate)
Disconnect from the FTP server. |
byte[] |
downloadByteArray(java.lang.String remoteFileName)
Download a file from the FTP server into a byte array. |
void |
downloadFile(java.lang.String localFileName,
java.lang.String remoteFileName)
Download a file from the FTP server . |
void |
downloadFile(java.lang.String localFileName,
java.lang.String remoteFileName,
WriteMode writeMode)
Download a file from the FTP server . |
FileTransferInputStream |
downloadStream(java.lang.String remoteFileName)
Download a file from the FTP server as a stream. |
static void |
downloadURLFile(java.lang.String localFileName,
java.lang.String ftpURL)
Downloads the given file to the given FTP URL. |
static FileTransferInputStream |
downloadURLStream(java.lang.String ftpURL)
Open an InputStream for the given FTP URL. |
java.lang.String |
executeCommand(java.lang.String command)
Request that the remote server execute the literal command supplied. |
boolean |
exists(java.lang.String remoteFileName)
Determine if a remote file exists. |
AdvancedFTPSettings |
getAdvancedFTPSettings()
Get the advanced FTP configuration parameters object |
AdvancedGeneralSettings |
getAdvancedSettings()
Get the advanced general configuration parameters object, for none protocol specific parameters |
FTPTransferType |
getContentType()
Get the current content type for all connections. |
FTPReply |
getLastReply()
Gets the last reply from the server, whether valid or not |
java.util.Date |
getModifiedTime(java.lang.String remoteFileName)
Get the modified-time of a remote file. |
int |
getNetworkBufferSize()
Get the size of the network buffers (SO_SNDBUF and SO_RCVBUF). |
java.lang.String |
getPassword()
Get the current user password. |
java.lang.String |
getRemoteDirectory()
Get the current remote directory. |
java.lang.String |
getRemoteHost()
Returns the IP address or name of the remote host. |
int |
getRemotePort()
Returns the port being connected to on the remote server. |
long |
getSize(java.lang.String remoteFileName)
Get the size of a remote file. |
FileStatistics |
getStatistics()
Get statistics on file transfers and deletions. |
java.lang.String |
getSystemType()
Get a string that represents the remote system that the client is logged into. |
int |
getTimeout()
Returns the timeout for socket connections. |
java.lang.String |
getUserName()
Get the current user name. |
boolean |
isConnected()
Is this client currently connected to the server? |
boolean |
isDetectContentType()
Get the detect content type flag |
void |
manualLogin()
Perform a manual login using the credentials that have been set. |
protected static void |
prepareURLTransfer(java.net.URL url,
FileTransferClientInterface client)
|
void |
rename(java.lang.String renameFromName,
java.lang.String renameToName)
Rename a remote file or directory. |
void |
setContentType(FTPTransferType type)
Set the transfer type for all connections, either ASCII or binary. |
void |
setDetectContentType(boolean detectContentType)
Set auto detect of filetypes on or off. |
void |
setEventListener(EventListener listener)
Set the event listener for transfer event notification |
void |
setModifiedTime(java.lang.String remoteFileName,
java.util.Date modifiedTime)
Set the modified-time of a remote file. |
void |
setNetworkBufferSize(int networkBufferSize)
Set the size of the network buffers (SO_SNDBUF and SO_RCVBUF). |
void |
setPassword(java.lang.String password)
Set the password of the user to log in with. |
void |
setRemoteHost(java.lang.String remoteHost)
Set the IP address or name of the remote host This may only be done if the client is not already connected to the server. |
void |
setRemotePort(int remotePort)
Set the port to connect to on the remote server. |
void |
setTimeout(int timeout)
Set the timeout for socket connections. |
void |
setUserName(java.lang.String userName)
Set the name of the user to log in with. |
java.lang.String |
uploadFile(java.lang.String localFileName,
java.lang.String remoteFileName)
Upload a file to the FTP server. |
java.lang.String |
uploadFile(java.lang.String localFileName,
java.lang.String remoteFileName,
WriteMode writeMode)
Upload a file to the FTP server. |
FileTransferOutputStream |
uploadStream(java.lang.String remoteFileName)
Upload a file to the FTP server by writing to a stream. |
FileTransferOutputStream |
uploadStream(java.lang.String remoteFileName,
WriteMode writeMode)
Upload a file to the FTP server by writing to a stream. |
static void |
uploadURLFile(java.lang.String localFileName,
java.lang.String ftpURL)
Uploads the given file to the given FTP URL. |
static FileTransferOutputStream |
uploadURLStream(java.lang.String ftpURL)
Open an OutputStream for the given FTP URL. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected com.enterprisedt.net.ftp.internal.ConnectionContext masterContext
protected com.enterprisedt.net.ftp.internal.EventAggregator eventAggregator
protected EventListener listener
| Constructor Detail |
|---|
public FileTransferClient()
| Method Detail |
|---|
protected void checkConnection(boolean shouldBeConnected)
throws FTPException
FTPException - Thrown if the client has not connected to the server.public boolean isConnected()
isConnected in interface FileTransferClientInterfacepublic java.lang.String getRemoteHost()
getRemoteHost in interface FileTransferClientInterface
public void setRemoteHost(java.lang.String remoteHost)
throws FTPException
setRemoteHost in interface FileTransferClientInterfaceremoteHost - The IP address or name of the remote host
FTPException - Thrown if the client is already connected to the server.public int getTimeout()
getTimeout in interface FileTransferClientInterface
public void setTimeout(int timeout)
throws FTPException
setTimeout in interface FileTransferClientInterfacetimeout - the timeout to use in milliseconds
FTPException - Thrown if the client is already connected to the server.public int getNetworkBufferSize()
getNetworkBufferSize in interface FileTransferClientInterface
public void setNetworkBufferSize(int networkBufferSize)
throws FTPException
setNetworkBufferSize in interface FileTransferClientInterfacenetworkBufferSize - new buffer size to set
FTPExceptionpublic int getRemotePort()
getRemotePort in interface FileTransferClientInterface
public void setRemotePort(int remotePort)
throws FTPException
setRemotePort in interface FileTransferClientInterfaceremotePort - The port to use.
FTPException - Thrown if the client is already connected to the server.
public void setContentType(FTPTransferType type)
throws java.io.IOException,
FTPException
setContentType in interface FileTransferClientInterfacetype - transfer type
FTPException
java.io.IOException
FTPExceptionpublic FTPTransferType getContentType()
getContentType in interface FileTransferClientInterfacepublic void setDetectContentType(boolean detectContentType)
setDetectContentType in interface FileTransferClientInterfacedetectContentType - true if detecting content type, false if notpublic boolean isDetectContentType()
isDetectContentType in interface FileTransferClientInterface
public void setUserName(java.lang.String userName)
throws FTPException
setUserName in interface FileTransferClientInterfaceuserName - user-name to log in with.
FTPExceptionpublic java.lang.String getPassword()
getPassword in interface FileTransferClientInterface
public void setPassword(java.lang.String password)
throws FTPException
setPassword in interface FileTransferClientInterfacepassword - password to log in with.
FTPExceptionpublic java.lang.String getUserName()
getUserName in interface FileTransferClientInterfacepublic AdvancedFTPSettings getAdvancedFTPSettings()
getAdvancedFTPSettings in interface FileTransferClientInterfacepublic AdvancedGeneralSettings getAdvancedSettings()
getAdvancedSettings in interface FileTransferClientInterfacepublic void setEventListener(EventListener listener)
setEventListener in interface FileTransferClientInterfacelistener - event listener reference
public void connect()
throws FTPException,
java.io.IOException
connect in interface FileTransferClientInterfaceFTPException
java.io.IOException
public void manualLogin()
throws FTPException,
java.io.IOException
FTPException
java.io.IOException
protected static void prepareURLTransfer(java.net.URL url,
FileTransferClientInterface client)
throws java.io.IOException,
FTPException
url -
java.io.IOException
FTPExceptionpublic FileStatistics getStatistics()
getStatistics in interface FileTransferClientInterface
public java.lang.String executeCommand(java.lang.String command)
throws FTPException,
java.io.IOException
executeCommand in interface FileTransferClientInterfacecommand - command string
FTPException
java.io.IOExceptionpublic void cancelAllTransfers()
cancelAllTransfers in interface FileTransferClientInterfacepublic FTPReply getLastReply()
public java.lang.String getSystemType()
throws FTPException,
java.io.IOException
getSystemType in interface FileTransferClientInterfaceFTPException
java.io.IOException
public java.lang.String[] directoryNameList()
throws FTPException,
java.io.IOException
directoryNameList in interface FileTransferClientInterfaceFTPException, - IOException
FTPException
java.io.IOException
public java.lang.String[] directoryNameList(java.lang.String directoryName,
boolean isLongListing)
throws FTPException,
java.io.IOException
directoryNameList in interface FileTransferClientInterfacedirectoryName - name of the directory (generally not a path). Some
servers will accept a wildcard.isLongListing - true if the listing is a long format listing
FTPException, - IOException
FTPException
java.io.IOException
public FTPFile[] directoryList()
throws FTPException,
java.io.IOException,
java.text.ParseException
directoryList in interface FileTransferClientInterfaceFTPException, - IOException
java.text.ParseException
FTPException
java.io.IOException
public FTPFile[] directoryList(java.lang.String directoryName)
throws FTPException,
java.io.IOException,
java.text.ParseException
directoryList in interface FileTransferClientInterfacedirectoryName - name of the directory (generally not a path). Some
servers will accept a wildcard.
FTPException, - IOException
java.text.ParseException
FTPException
java.io.IOException
public void directoryList(java.lang.String directoryName,
DirectoryListCallback lister)
throws FTPException,
java.io.IOException,
java.text.ParseException
directoryList in interface FileTransferClientInterfacedirectoryName - name of the directory (generally not a path)
FTPException, - IOException
FTPException
java.io.IOException
java.text.ParseException
public byte[] downloadByteArray(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
downloadByteArray in interface FileTransferClientInterfaceremoteFileName - name of the remote file to be downloaded
FTPException
java.io.IOException
public void downloadFile(java.lang.String localFileName,
java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
downloadFile in interface FileTransferClientInterfacelocalFileName - name (or full path) of the local file to be downloaded toremoteFileName - name of the remote file to be downloaded
FTPException
java.io.IOException
public void downloadFile(java.lang.String localFileName,
java.lang.String remoteFileName,
WriteMode writeMode)
throws FTPException,
java.io.IOException
downloadFile in interface FileTransferClientInterfacelocalFileName - name (or full path) of the local file to be downloaded toremoteFileName - name of the remote file to be downloadedwriteMode - mode in which the file is written to the client machine
FTPException
java.io.IOException
public static FileTransferInputStream downloadURLStream(java.lang.String ftpURL)
throws java.net.MalformedURLException,
java.io.IOException,
FTPException
ftp://[user[:password]@]host[:port]/path. The stream should be closed when
the transfer is complete.
ftpURL - The URL must be of the form ftp://[user[:password]@]host[:port]/path.
java.net.MalformedURLException - Thrown when an invalid URL is provided.
java.io.IOException - Thrown when an I/O-related error occurs.
FTPException - Thrown when an FTP-protocol-related error occurs.
public static void downloadURLFile(java.lang.String localFileName,
java.lang.String ftpURL)
throws java.net.MalformedURLException,
java.io.IOException,
FTPException
ftp://[user[:password]@]host[:port]/path.
localFileName - Path to local fileftpURL - The URL must be of the form ftp://[user[:password]@]host[:port]/path.
java.net.MalformedURLException - Thrown when an invalid URL is provided.
java.io.IOException - Thrown when an I/O-related error occurs.
FTPException - Thrown when an FTP-protocol-related error occurs.
public FileTransferInputStream downloadStream(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
downloadStream in interface FileTransferClientInterfaceremoteFileName - name of the remote file to be downloaded
FTPException
java.io.IOException
public java.lang.String uploadFile(java.lang.String localFileName,
java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
uploadFile in interface FileTransferClientInterfacelocalFileName - name (or full path) of the local file to be downloaded toremoteFileName - name of the remote file to be downloaded (or null to generate a unique name)
FTPException
java.io.IOException
public java.lang.String uploadFile(java.lang.String localFileName,
java.lang.String remoteFileName,
WriteMode writeMode)
throws FTPException,
java.io.IOException
uploadFile in interface FileTransferClientInterfacelocalFileName - name (or full path) of the local file to be downloaded toremoteFileName - name of the remote file to be downloaded (or null to generate a unique name)writeMode - mode to write to the remote file with
FTPException
java.io.IOException
public FileTransferOutputStream uploadStream(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
FileTransferOutputStream.getRemoteFile()
uploadStream in interface FileTransferClientInterfaceremoteFileName - name of the remote file to be uploaded
FTPException
java.io.IOException
public FileTransferOutputStream uploadStream(java.lang.String remoteFileName,
WriteMode writeMode)
throws FTPException,
java.io.IOException
FileTransferOutputStream.getRemoteFile()
uploadStream in interface FileTransferClientInterfaceremoteFileName - name of the remote file to be uploadedwriteMode - mode for writing to the server (supporting use of append)
FTPException
java.io.IOException
public static FileTransferOutputStream uploadURLStream(java.lang.String ftpURL)
throws java.net.MalformedURLException,
java.io.IOException,
FTPException
ftp://[user[:password]@]host[:port]/path. The stream should
be closed when the transfer is complete.
ftpURL - The URL must be of the form ftp://[user[:password]@]host[:port]/path.
java.net.MalformedURLException - Thrown when an invalid URL is provided.
java.io.IOException - Thrown when an I/O-related error occurs.
FTPException - Thrown when an FTP-protocol-related error occurs.
public static void uploadURLFile(java.lang.String localFileName,
java.lang.String ftpURL)
throws java.net.MalformedURLException,
java.io.IOException,
FTPException
ftp://[user[:password]@]host[:port]/path.
localFileName - Path to local fileftpURL - The URL must be of the form ftp://[user[:password]@]host[:port]/path.
java.net.MalformedURLException - Thrown when an invalid URL is provided.
java.io.IOException - Thrown when an I/O-related error occurs.
FTPException - Thrown when an FTP-protocol-related error occurs.
public long getSize(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
getSize in interface FileTransferClientInterfaceremoteFileName - name of remote file
FTPException
java.io.IOException
public java.util.Date getModifiedTime(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
getModifiedTime in interface FileTransferClientInterfaceremoteFileName - name of remote file
FTPException
java.io.IOException
public void setModifiedTime(java.lang.String remoteFileName,
java.util.Date modifiedTime)
throws FTPException,
java.io.IOException
setModifiedTime in interface FileTransferClientInterfaceremoteFileName - name of remote filemodifiedTime - new modified time
FTPException
java.io.IOException
public boolean exists(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
exists in interface FileTransferClientInterfaceremoteFileName - name of remote file
FTPException
java.io.IOException
public void deleteFile(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
deleteFile in interface FileTransferClientInterfaceremoteFileName - name of remote file
FTPException
java.io.IOException
public void rename(java.lang.String renameFromName,
java.lang.String renameToName)
throws FTPException,
java.io.IOException
rename in interface FileTransferClientInterfacerenameFromName - original namerenameToName - new name
FTPException, - IOException
FTPException
java.io.IOException
public void changeDirectory(java.lang.String directoryName)
throws FTPException,
java.io.IOException
changeDirectory in interface FileTransferClientInterfacedirectoryName - name the remote directory to change into
FTPException, - IOException
FTPException
java.io.IOException
public void changeToParentDirectory()
throws FTPException,
java.io.IOException
changeToParentDirectory in interface FileTransferClientInterfaceFTPException, - IOException
FTPException
java.io.IOException
public java.lang.String getRemoteDirectory()
throws java.io.IOException,
FTPException
getRemoteDirectory in interface FileTransferClientInterfaceFTPException
java.io.IOException
public void createDirectory(java.lang.String directoryName)
throws FTPException,
java.io.IOException
createDirectory in interface FileTransferClientInterfacedirectoryName - name the remote directory to create
FTPException, - IOException
FTPException
java.io.IOException
public void deleteDirectory(java.lang.String directoryName)
throws FTPException,
java.io.IOException
deleteDirectory in interface FileTransferClientInterfacedirectoryName - name the remote directory to create
FTPException, - IOException
FTPException
java.io.IOException
public void disconnect()
throws FTPException,
java.io.IOException
disconnect in interface FileTransferClientInterfaceFTPException, - IOException
FTPException
java.io.IOException
public void disconnect(boolean immediate)
throws FTPException,
java.io.IOException
disconnect in interface FileTransferClientInterfaceFTPException, - IOException
FTPException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||