Package com.enterprisedt.net.ftp
Interface FileTransferClientInterface
- All Known Implementing Classes:
AsyncFileTransferClient,FileTransferClient,SecureFileTransferClient
public interface FileTransferClientInterface
Easy to use FTP client interface
- Version:
- $Revision$
- Author:
- Bruce Blackshaw
-
Method Summary
Modifier and TypeMethodDescriptionvoidCancel current transfer if underwayvoidchangeDirectory(String directoryName) Change directory on the FTP server.voidChange to parent directory on the FTP server.voidconnect()Make a connection to the FTP server.voidcreateDirectory(String directoryName) Create directory on the FTP server.voiddeleteDirectory(String directoryName) Delete directory on the FTP server.voiddeleteFile(String remoteFileName) Deletes a remote file.FTPFile[]List the current directory on the FTP server.FTPFile[]directoryList(String directoryName) List a directory on the FTP server.voiddirectoryList(String directoryName, DirectoryListCallback lister) List a directory on the FTP server.String[]List the names of files and directories in the current directory on the FTP server.String[]directoryNameList(String directoryName, boolean isLongListing) List the names of files and directories of a directory on the FTP server.voidDisconnect from the FTP server.voiddisconnect(boolean immediate) Disconnect from the FTP server.byte[]downloadByteArray(String remoteFileName) Download a file from the FTP server into a byte array.voiddownloadFile(String localFileName, String remoteFileName) Download a file from the FTP server .voiddownloadFile(String localFileName, String remoteFileName, WriteMode writeMode) Download a file from the FTP server .downloadStream(String remoteFileName) Download a file from the FTP server as a stream.executeCommand(String command) Request that the remote server execute the literal command supplied.booleanDetermine if a remote file exists.Get the advanced FTP configuration parameters objectGet the advanced general configuration parameters objectGet the current content type for all connections.getModifiedTime(String remoteFileName) Get the modified-time of a remote file.intGet the size of the network buffers (SO_SNDBUF and SO_RCVBUF).Get the current user password.Get the current remote directory.Returns the IP address or name of the remote host.intReturns the port being connected to on the remote server.longGet the size of a remote file.Get statistics on file transfers and deletions.Get a string that represents the remote system that the client is logged into.intReturns the timeout for socket connections.Get the current user name.booleanIs this client currently connected to the server?booleanGet the detect content type flagvoidRename a remote file or directory.voidSet the transfer type for all connections, either ASCII or binary.voidsetDetectContentType(boolean detectContentType) Set auto detect of filetypes on or off.voidsetEventListener(EventListener listener) Set the event listener for transfer event notificationvoidsetModifiedTime(String remoteFileName, Date modifiedTime) Set the modified-time of a remote file.voidsetNetworkBufferSize(int networkBufferSize) Set the size of the network buffers (SO_SNDBUF and SO_RCVBUF).voidsetPassword(String password) Set the password of the user to log in with.voidsetRemoteHost(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.voidsetRemotePort(int remotePort) Set the port to connect to on the remote server.voidsetTimeout(int timeout) Set the timeout for socket connections.voidsetUserName(String userName) Set the name of the user to log in with.uploadFile(String localFileName, String remoteFileName) Upload a file to the FTP server.uploadFile(String localFileName, String remoteFileName, WriteMode writeMode) Upload a file to the FTP server.uploadStream(String remoteFileName) Upload a file to the FTP server by writing to a stream.uploadStream(String remoteFileName, WriteMode writeMode) Upload a file to the FTP server by writing to a stream.
-
Method Details
-
isConnected
boolean isConnected()Is this client currently connected to the server?- Returns:
- true if connected, false otherwise
-
getRemoteHost
String getRemoteHost()Returns the IP address or name of the remote host.- Returns:
- Returns the remote host.
-
setRemoteHost
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.- Parameters:
remoteHost- The IP address or name of the remote host- Throws:
FTPException- Thrown if the client is already connected to the server.
-
getTimeout
int getTimeout()Returns the timeout for socket connections.- Returns:
- Returns the connection timeout in milliseconds
-
setTimeout
Set the timeout for socket connections. Can only do this if not already connected.- Parameters:
timeout- the timeout to use in milliseconds- Throws:
FTPException- Thrown if the client is already connected to the server.
-
getNetworkBufferSize
int getNetworkBufferSize()Get the size of the network buffers (SO_SNDBUF and SO_RCVBUF).- Returns:
- network buffer size
-
setNetworkBufferSize
Set the size of the network buffers (SO_SNDBUF and SO_RCVBUF).- Parameters:
networkBufferSize- new buffer size to set- Throws:
FTPException
-
getRemotePort
int getRemotePort()Returns the port being connected to on the remote server.- Returns:
- Returns the port being connected to on the remote server.
-
setRemotePort
Set the port to connect to on the remote server. Can only do this if not already connected.- Parameters:
remotePort- The port to use.- Throws:
FTPException- Thrown if the client is already connected to the server.
-
setContentType
Set the transfer type for all connections, either ASCII or binary. Setting applies to all subsequent transfers that are initiated.- Parameters:
type- transfer type- Throws:
FTPExceptionIOExceptionFTPException
-
getContentType
FTPTransferType getContentType()Get the current content type for all connections.- Returns:
- transfer type
-
setDetectContentType
void setDetectContentType(boolean detectContentType) Set auto detect of filetypes on or off. If on, the transfer mode is switched from ASCII to binary and vice versa depending on the extension of the file. After the transfer, the mode is always returned to what it was before the transfer was performed. The default is off. If the filetype is unknown, the transfer mode is unchanged- Parameters:
detectContentType- true if detecting content type, false if not
-
isDetectContentType
boolean isDetectContentType()Get the detect content type flag- Returns:
- true if we are detecting binary and ASCII transfers from the file type
-
setUserName
Set the name of the user to log in with. Can only do this if not already connected.- Parameters:
userName- user-name to log in with.- Throws:
FTPException
-
getPassword
String getPassword()Get the current user password.- Returns:
- current user password
-
setPassword
Set the password of the user to log in with. Can only do this if not already connected.- Parameters:
password- password to log in with.- Throws:
FTPException
-
getUserName
String getUserName()Get the current user name.- Returns:
- current user name
-
getAdvancedFTPSettings
AdvancedFTPSettings getAdvancedFTPSettings()Get the advanced FTP configuration parameters object- Returns:
- advanced parameters
-
getAdvancedSettings
AdvancedGeneralSettings getAdvancedSettings()Get the advanced general configuration parameters object- Returns:
- advanced parameters
-
setEventListener
Set the event listener for transfer event notification- Parameters:
listener- event listener reference
-
connect
Make a connection to the FTP server.- Throws:
FTPExceptionIOException
-
getStatistics
FileStatistics getStatistics()Get statistics on file transfers and deletions.- Returns:
- FTPStatistics
-
executeCommand
Request that the remote server execute the literal command supplied. In FTP, this is the equivalent of 'quote'. It could be used to send a SITE command to the server, e.g. "SITE recfm=FB lrecl=180 blksize=5400".- Parameters:
command- command string- Returns:
- result string returned by server
- Throws:
FTPExceptionIOException
-
cancelAllTransfers
void cancelAllTransfers()Cancel current transfer if underway -
getSystemType
Get a string that represents the remote system that the client is logged into.- Returns:
- system string
- Throws:
FTPExceptionIOException
-
directoryNameList
List the names of files and directories in the current directory on the FTP server.- Returns:
- String[]
- Throws:
FTPExceptionIOException
-
directoryNameList
String[] directoryNameList(String directoryName, boolean isLongListing) throws FTPException, IOException List the names of files and directories of a directory on the FTP server.- Parameters:
directoryName- name of the directory (generally not a path). Some servers will accept a wildcard.isLongListing- true if the listing is a long format listing- Returns:
- String[]
- Throws:
FTPExceptionIOException
-
directoryList
List the current directory on the FTP server.- Throws:
ParseExceptionFTPExceptionIOException
-
directoryList
List a directory on the FTP server.- Parameters:
directoryName- name of the directory (generally not a path). Some servers will accept a wildcard.- Throws:
ParseExceptionFTPExceptionIOException
-
directoryList
void directoryList(String directoryName, DirectoryListCallback lister) throws FTPException, IOException, ParseException List a directory on the FTP server.- Parameters:
directoryName- name of the directory (generally not a path)- Throws:
FTPExceptionIOExceptionParseException
-
downloadByteArray
Download a file from the FTP server into a byte array.- Parameters:
remoteFileName- name of the remote file to be downloaded- Throws:
FTPExceptionIOException
-
downloadFile
Download a file from the FTP server .- Parameters:
localFileName- name (or full path) of the local file to be downloaded toremoteFileName- name of the remote file to be downloaded- Throws:
FTPExceptionIOException
-
downloadFile
void downloadFile(String localFileName, String remoteFileName, WriteMode writeMode) throws FTPException, IOException Download a file from the FTP server .- Parameters:
localFileName- 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- Throws:
FTPExceptionIOException
-
downloadStream
Download a file from the FTP server as a stream. The close() method must be called on the stream once the stream has been read.- Parameters:
remoteFileName- name of the remote file to be downloaded- Returns:
- InputStream
- Throws:
FTPExceptionIOException
-
uploadFile
Upload a file to the FTP server. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file.- Parameters:
localFileName- 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)- Returns:
- name of remote file
- Throws:
FTPExceptionIOException
-
uploadFile
String uploadFile(String localFileName, String remoteFileName, WriteMode writeMode) throws FTPException, IOException Upload a file to the FTP server. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file.- Parameters:
localFileName- 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- Returns:
- name of remote file
- Throws:
FTPExceptionIOException
-
uploadStream
Upload a file to the FTP server by writing to a stream. The close() method must be called on the stream once the stream has been read. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file. This name can be obtained afterwards from- Parameters:
remoteFileName- name of the remote file to be uploaded- Returns:
- FTPOutputStream
- Throws:
FTPExceptionIOException
-
uploadStream
FileTransferOutputStream uploadStream(String remoteFileName, WriteMode writeMode) throws FTPException, IOException Upload a file to the FTP server by writing to a stream. The close() method *must* be called on the stream once the stream has been read. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file. This name can be obtained afterwards from- Parameters:
remoteFileName- name of the remote file to be uploadedwriteMode- mode for writing to the server (supporting use of append)- Returns:
- FTPOutputStream
- Throws:
FTPExceptionIOException
-
getSize
Get the size of a remote file.- Parameters:
remoteFileName- name of remote file- Returns:
- long
- Throws:
FTPExceptionIOException
-
getModifiedTime
Get the modified-time of a remote file. May not be supported by all servers.- Parameters:
remoteFileName- name of remote file- Returns:
- Date
- Throws:
FTPExceptionIOException
-
setModifiedTime
Set the modified-time of a remote file. May not be supported by all servers.- Parameters:
remoteFileName- name of remote filemodifiedTime- new modified time- Throws:
FTPExceptionIOException
-
exists
Determine if a remote file exists.- Parameters:
remoteFileName- name of remote file- Throws:
FTPExceptionIOException
-
deleteFile
Deletes a remote file.- Parameters:
remoteFileName- name of remote file- Throws:
FTPExceptionIOException
-
rename
Rename a remote file or directory.- Parameters:
renameFromName- original namerenameToName- new name- Throws:
FTPExceptionIOException
-
changeDirectory
Change directory on the FTP server.- Parameters:
directoryName- name the remote directory to change into- Throws:
FTPExceptionIOException
-
changeToParentDirectory
Change to parent directory on the FTP server.- Throws:
FTPExceptionIOException
-
getRemoteDirectory
Get the current remote directory.- Returns:
- current remote directory
- Throws:
FTPExceptionIOException
-
createDirectory
Create directory on the FTP server.- Parameters:
directoryName- name the remote directory to create- Throws:
FTPExceptionIOException
-
deleteDirectory
Delete directory on the FTP server. The directory must be empty. Note that edtFTPj/PRO supports recursive directory deletions.- Parameters:
directoryName- name the remote directory to create- Throws:
FTPExceptionIOException
-
disconnect
Disconnect from the FTP server.- Throws:
FTPExceptionIOException
-
disconnect
Disconnect from the FTP server.- Throws:
FTPExceptionIOException
-