public class Ftps
extends java.lang.Object
implements java.lang.AutoCloseable
Example Usage:
// create new Ftps instance Ftps ftps = new Ftps("ftp.myserver.com","jsmith","secret"); try { // establish connection ftps.connect(); // print out directory listing System.out.println(ftps.getDirListingAsString()); // disconnect from FTPS server ftps.disconnect(); } catch(Exception e) { System.out.println(e); }
Modifier and Type | Class and Description |
---|---|
static interface |
Ftps.ConnectionStrategy
The FTP client connection strategy.
|
Modifier and Type | Field and Description |
---|---|
static int |
ASCII
Flag to indicate that ASCII transfer mode is used.
|
static Ftps.ConnectionStrategy |
AUTH_SSL
Connection type for AUTH SSL FTP session.
|
static Ftps.ConnectionStrategy |
AUTH_TLS
Connection type for AUTH TLS FTP session (default).
|
static int |
AUTO
Flag to indicate that automatic transfer mode detection is used.
|
static int |
BINARY
Flag to indicate that BINARY transfer mode is used.
|
static java.lang.String |
CURRENT_DIR
Represents the current directory.
|
static Ftps.ConnectionStrategy |
IMPLICIT_SSL
Connection type for implicit SSL session.
|
static java.lang.String |
UP_DIR
Represents the parent directory of current directory.
|
Constructor and Description |
---|
Ftps()
Creates a new Ftps instance.
|
Ftps(java.lang.String host,
java.lang.String user,
java.lang.String pwd)
Creates a new Ftps instance.
|
Ftps(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
java.io.File localDirectory)
Creates new Ftp instance.
|
Ftps(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
int port)
Creates a new Ftp instance.
|
Ftps(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
java.lang.String account)
Creates a new Ftps instance.
|
Modifier and Type | Method and Description |
---|---|
void |
abortDownloadThread(java.lang.String file)
Cancel the given file transfer thread.
|
void |
abortDownloadThreads()
Abort all download threads.
|
void |
abortUploadThread(java.lang.String file)
Cancel the given file transfer thread.
|
void |
abortUploadThreads()
Cancel all upload threads.
|
void |
addFtpListener(FtpListener listener)
Adds FTP event listener.
|
void |
addFtpsCertificateVerifier(FtpsCertificateVerifier listener)
Deprecated.
|
void |
changePassword(java.lang.String oldPassword,
java.lang.String newPassword)
Changes the password for current account.
|
boolean |
checksum(byte[] data,
java.lang.String remoteFile)
Compares checksum of the local data and remote file.
|
boolean |
checksum(java.io.File localfile,
java.lang.String remoteFile)
Compares checksum of the local and remote files.
|
void |
clearCommandChannel()
Clears command channel.
|
void |
clearProxySettings()
Clears proxy server values.
|
void |
close() |
Ftps |
connect()
Connects to FTP server and performs login.
|
Ftps |
connect(boolean login)
Connects to FTP server and optionally performs login.
|
void |
deleteDir(java.lang.String remoteDirectory)
Deletes directory from FTP server.
|
void |
deleteDir(java.lang.String remoteDirectory,
boolean recurse)
Deletes directory from FTP server.
|
void |
deleteFile(java.lang.String remoteFile)
Deletes remote file from FTP server.
|
void |
disconnect()
Quits the FTP session and disconnects from the FTP server.
|
void |
download(java.io.OutputStream out,
java.lang.String remoteFile)
Downloads file from FTP server and writes contents to provided
OutputStream . |
java.io.File |
download(java.lang.String remoteFile)
Downloads file from FTP server.
|
java.io.File |
download(java.lang.String localFile,
java.lang.String remoteFile)
Downloads file from FTP server.
|
void |
downloadDir(java.lang.String remoteDir)
Downloads remote directory and contents recursively from FTP server.
|
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
boolean performChecksum)
Downloads remote directory and contents recursively from FTP server.
|
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
boolean performChecksum,
int threadCount)
Download directory.
|
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
int retryInterval,
boolean performChecksum)
Downloads remote directory and contents recursively from FTP server.
|
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
int retryInterval,
boolean performChecksum,
int threadCount)
Downloads remote directory and contents from FTP server.
|
java.lang.String |
getAccount()
Gets optional account of FTP server.
|
boolean |
getAutoDetectIpv6()
Get auto detect Ipv6 detection mode.
|
int |
getBlockTransferSize()
Gets blocksize for use in transferring files.
|
java.lang.String |
getCharacterEncoding()
Deprecated.
use the getWireEncoding method
|
boolean |
getCompression()
Gets whether the data is compressed during the transfering.
|
boolean |
getConnectBeforeCommand()
Gets whether connection will be established before sending data transfer command.
|
Ftps.ConnectionStrategy |
getConnectionType()
Returns the current connection type.
|
javax.net.ssl.SSLContext |
getContext()
Obtains the current SSL context.
|
java.lang.String |
getContextAlgorithm()
Gets algorithm used for SSL communications in default context.
|
java.lang.String |
getContextAlgorithmProvider()
Gets provider used for X509 algorithm in default context.
|
java.lang.String |
getContextKeystoreProvider()
Gets keystore provider used for default context.
|
java.lang.String |
getContextProtocol()
Gets protocol used for SSL communications in default context.
|
java.lang.String |
getContextProtocolProvider()
Gets provider used for TLS protocol in default context.
|
int |
getDataPort()
Deprecated.
Replaced by getDataPortStart and getDataPortEnd
|
int |
getDataPortEnd()
Gets the data port end range for incoming non-passive (active) data connections.
|
int |
getDataPortStart()
Gets the data port start range for incoming non-passive (active) data connections.
|
boolean |
getDebug()
Gets debugging state.
|
java.io.PrintStream |
getDebugStream()
Gets PrintStream used in reporting debug statements.
|
java.lang.String |
getDir()
Gets current working directory of FTP server.
|
java.util.Enumeration |
getDirListing()
Gets directory listing from FTP server.
|
java.util.Enumeration |
getDirListing(java.lang.String filter)
Gets file listing of files matching filter criteria.
|
java.lang.String |
getDirListingAsString()
Gets raw directory listing of files on FTP server.
|
java.lang.String |
getDirListingAsString(java.lang.String filter)
Gets raw directory listing of files matching filter criteria.
|
java.util.Enumeration |
getDirListingRegex(java.lang.String filter)
Gets directory listing from FTP server returning only file and directory names that match
the regular expression.
|
java.lang.String |
getDirListingRegexAsString(java.lang.String filter)
Gets directory listing from FTP server returning only file and directory names that match
the regular expression.
|
java.lang.String |
getDiskEncoding()
Gets character encoding used when reading data from disk for ASCII file transfer.
|
java.lang.String[] |
getEnabledCiphers()
Returns user-defined enabled SSL cipher suites.
|
boolean |
getErrorOnSizeCommand()
Gets whether an exception should be thrown when downloading a file and server does not support SIZE command.
|
java.util.Enumeration |
getFeatures()
Returns supported server features.
|
long |
getFilesize(java.lang.String remoteFile)
Gets filesize of remote file from FTP server as represented in ASCII.
|
java.util.Date |
getFileTimestamp(java.lang.String remoteFile)
Gets date/timestamp of remote file from FTP server.
|
FtpFileParser |
getFtpFileParser()
Gets the
FtpFileParser used to parse directory listing returned when
invoking Ftp#getDirListing method. |
FtpsCertificateVerifier |
getFtpsCertificateVerifier()
Gets FTPS certificate verifier.
|
java.lang.String |
getHostname()
Gets hostname of FTP server.
|
java.io.InputStream |
getInputStream(java.lang.String remoteFile,
long offset)
Gets a
InputStream from FTP server for the purposes of downloading a file. |
int |
getLinger()
Gets the linger time for closing data sockets.
|
java.util.LinkedList |
getListeners()
Get listeners.
|
java.lang.String |
getLocalChecksum(java.io.File localFile)
Returns local checksum.
|
java.io.File |
getLocalDir()
Gets local directory to be used in FTP session.
|
java.util.Enumeration |
getLocalDirListing()
Gets local directory listing.
|
java.util.Enumeration |
getMachineDirListing(java.lang.String dirname)
Gets directory listing using MLSD command.
|
java.util.Enumeration |
getMachineDirListing(java.lang.String dirname,
java.lang.String filter)
Gets file listing of specified directory using MLSD command.
|
FtpFile |
getMachineFileListing(java.lang.String filename)
Gets the file description for the specified filename using MLST command.
|
int |
getMode()
Gets data transfer mode for current session.
|
java.util.Enumeration |
getNameListing()
Gets directory listing of files on FTP server using NLST command.
|
java.util.Enumeration |
getNameListing(java.lang.String filter)
Gets directory listing of files on FTP server matching filter criteria
and using NLST command.
|
java.lang.String |
getNATAddress()
Get the NAT address.
|
java.io.OutputStream |
getOutputStream(java.lang.String fileName,
long off,
boolean append)
Gets an
OutputStream from FTP server for the purposes of uploading a file. |
boolean |
getPassive()
Gets whether passive mode should be used.
|
java.lang.String |
getPassword()
Returns current FTP user password.
|
int |
getPort()
Gets port of FTP server.
|
java.lang.String |
getPortAddress()
Gets the external address to use when using active connections.
|
boolean |
getPreserveDownloadTimestamp()
Get preserve download timestamp.
|
boolean |
getPreserveUploadTimestamp()
Get upload modification time.
|
java.lang.String |
getProxyHostname()
Get proxy hostname.
|
java.lang.String |
getProxyPassword()
Get proxy password.
|
int |
getProxyPort()
Get proxy port.
|
java.lang.String |
getProxyType()
Get proxy type.
|
java.lang.String |
getProxyUsername()
Get proxy username.
|
int |
getRecursiveDirectoryFileCount(java.lang.String directory)
Get size of all files rescursively in a given remote directory.
|
long |
getRecursiveDirectorySize(java.lang.String directory)
Get size of all files rescursively in a given remote directory.
|
java.lang.String |
getRemoteFileChecksum(java.lang.String remoteFile)
Returns remote file checksum.
|
java.util.Vector |
getRemoteFileList(java.lang.String remoteDir)
Gets all the remote files from the current directory and subdirectories.
|
int |
getResponseCode()
Gets response code from last FTP command.
|
boolean |
getServerFeaturesCommandSuccessful() |
boolean |
getShutdownCCC()
Gets whether SSL connection should be shutdown after successfully issuing
CCC command.
|
javax.net.ssl.HandshakeCompletedListener |
getSslHandshakeCompletedListener() |
java.lang.String |
getSystemType()
Gets the system type of remote FTP server.
|
boolean |
getTcpNoDelay() |
int |
getTimeout()
Gets the timeout for opening connection to FTP server.
|
java.util.TimeZone |
getTimeZone()
Get the associated timezone.
|
boolean |
getUseEPRT()
Gets whether to use EPSV or PORT command for data tranfers.
|
boolean |
getUseEPSV()
Gets whether to use EPSV or PASV command for data tranfers.
|
java.lang.String |
getUsername()
Gets username of FTP user.
|
java.lang.String |
getWireEncoding()
Gets character encoding used when issuing commands and reading files from FTP server in ASCII mode.
|
void |
interrupt()
Interrupts the current data transfer and sets interrupted flag to
true . |
boolean |
interrupted()
Checks if transfer process was interrupted.
|
boolean |
isConnected()
Checks if client is connected to FTP server.
|
boolean |
isFeatureSupported(java.lang.String command)
Looks for the command argument into the server features list to validate if it is supported
|
java.lang.String |
issueCommand(java.lang.String cmd)
Issues the command to FTP server.
|
java.lang.String |
issueCommandCheck(java.lang.String cmd)
Issues command to FTP server.
|
void |
login()
Logs into FTP server after establishing a connection.
|
void |
makeDir(java.lang.String newDirectory)
Makes directory on FTP server.
|
void |
makeDirRecursive(java.lang.String newDirectory)
Makes directory on FTP server, creating subdirectories if necessary.
|
java.io.File |
makeLocalDir(java.lang.String directoryName)
Creates local directory.
|
void |
mdelete(java.lang.String filter)
Deletes multiple files matching regular in FTP server's current directory.
|
void |
mdownload(java.util.Enumeration fileNames)
Downloads specified files in current working remote directory from FTP
server to local directory.
|
void |
mdownload(java.lang.String filter)
Downloads multiple files matching regular expression from FTP server's current
directory.
|
void |
mupload(java.util.Enumeration fileNames)
Uploads multiple files to FTP server
Uploads are performed relative to current local directory.
|
void |
mupload(java.lang.String filter)
Uploads multiple files matching regular expression to FTP server's current directory.
|
java.lang.String |
noop()
Sends a NOOP (No Operation) command to FTP server.
|
java.lang.String |
readResponse()
Reads response from FTP server.
|
void |
removeFtpListener(FtpListener listener)
Removes specified FTP event listener.
|
void |
renameFile(java.lang.String remoteFile,
java.lang.String newFile)
Renames remote file on FTP server.
|
void |
reset()
Resets the interrupted flag to
false . |
java.io.File |
resumeDownload(java.lang.String remoteFile,
long off)
Resumes download of file from FTP server.
|
java.io.File |
resumeDownload(java.lang.String localFile,
java.lang.String remoteFile,
long off)
Resumes download of file from FTP server.
|
void |
resumeUpload(java.io.File localFile,
long off)
Resumes upload of file to FTP server.
|
void |
resumeUpload(java.io.File localFile,
java.lang.String remoteFile,
long off)
Resumes upload of file to FTP server.
|
void |
resumeUpload(java.lang.String localFile,
long off)
Resumes upload of file to FTP server.
|
void |
resumeUpload(java.lang.String localFile,
java.lang.String remoteFile,
long off)
Resumes upload of file to FTP server.
|
void |
setAccount(java.lang.String account)
Sets optional account of FTP server.
|
void |
setAscii()
Sets data transfer mode to ASCII.
|
void |
setAuto(boolean auto)
Sets data transfer mode to automatic detect.
|
void |
setAutoDetectIpv6(boolean value)
Set auto detect Ipv6 detection mode.
|
void |
setBinary()
Sets data transfer mode to binary.
|
void |
setBlockTransferSize(int blockSize)
Sets block size for use in transferring files.
|
void |
setCharacterEncoding(java.lang.String encoding)
Deprecated.
use the setWireEncoding method
|
void |
setClientCertificates(java.security.KeyStore keystore,
java.lang.String password)
Sets optional client certificate to be used during authentication.
|
void |
setClientCertificates(java.lang.String filename,
java.lang.String password)
Sets optional client certificate to be used during authentication.
|
void |
setClientCertificates(java.lang.String filename,
java.lang.String password,
java.lang.String storetype)
Sets optional client certificate to be used during authentication.
|
void |
setCompression(boolean compression)
Sets whether the data will be compressed during the transfer.
|
void |
setConnectBeforeCommand(boolean value)
Gets whether connection will be established before sending data transfer command.
|
void |
setConnectionType(Ftps.ConnectionStrategy connectionType)
Sets the connection type.
|
void |
setContext(javax.net.ssl.SSLContext context)
Sets the current SSL context.
|
void |
setContextAlgorithm(java.lang.String algorithm)
Sets algorithm used for SSL communications in default context.
|
void |
setContextAlgorithmProvider(java.lang.String provider)
Sets provider used for X509 algorithm in default context.
|
void |
setContextKeystoreProvider(java.lang.String provider)
Sets provider used for keystore in default context.
|
void |
setContextProtocol(java.lang.String protocol)
Sets protocol used for SSL communications in default context.
|
void |
setContextProtocolProvider(java.lang.String provider)
Sets provider used for TLS protocol in default context.
|
void |
setDataPort(int dataPort)
Deprecated.
Replaced by setDataPortRange
|
void |
setDataPortRange(int dataPortStart,
int dataPortEnd)
Sets the data port range for incoming non-passive (active) connections.
|
void |
setDebug(boolean debug)
Sets debugging state.
|
void |
setDebugStream(java.io.PrintStream debugStream)
Sets PrintStream used in reporting debug statements.
|
void |
setDir(java.lang.String remoteDirectory)
Sets current directory on FTP server.
|
void |
setDirUp()
Sets current directory on FTP server to parent directory.
|
void |
setDiskEncoding(java.lang.String encoding)
Sets character set used when reading data from disk for ASCII file transfer.
|
void |
setEnabledCiphers(java.lang.String[] enabledCiphers)
Sets user-defined enabled SSL cipher suites.
|
void |
setErrorOnSizeCommand(boolean error)
Sets whether an exception should be thrown when downloading a file and server does not support SIZE command.
|
void |
setFileCreationTime(java.lang.String remoteName,
java.util.Date date)
Sets file creation time with a new value.
|
void |
setFileModificationTime(java.lang.String remoteName,
java.util.Date date)
Sets the file modification time with a new value.
|
void |
setFileTimestamp(java.lang.String remoteName,
java.util.Date dateFile)
Sets date/timestamp of remote file from FTP server.
|
void |
setFtpFileParser(FtpFileParser parser)
Sets the
FtpFileParser used to parse directory listing returned when
invoking Ftps#getDirListing method. |
void |
setFtpsCertificateVerifier(FtpsCertificateVerifier listener)
Sets FTPS certificate verifier.
|
void |
setHostname(java.lang.String host)
Sets hostname of FTP server.
|
void |
setHostname(java.lang.String host,
boolean ensureConnected)
Sets the hostname of FTP Server.
|
void |
setLinger(int linger)
Sets the linger time for closing data sockets.
|
void |
setListeners(java.util.LinkedList listeners)
Set the list of listeners.
|
void |
setLocalDir(java.io.File localDirectory)
Sets local directory to be used in FTP session.
|
void |
setNATAddress(java.lang.String ipAddress)
Sets a NAT address which will be used for PASV file transfers.
|
void |
setPassive(boolean passive)
Sets whether passive mode should be used.
|
void |
setPassword(java.lang.String password)
Sets password of FTP user.
|
void |
setPort(int port)
Sets port of FTP server.
|
void |
setPortAddress(java.lang.String string)
Sets the external address to use when using active connections
using the PORT command.
|
void |
setPreserveDownloadTimestamp(boolean value)
Set the preserve download timestamp value.
|
void |
setPreserveUploadTimestamp(boolean value)
Set upload modification time, replaces the last modified timestamp with that of the local file after upload is complete.
|
void |
setProtectionLevel(char level)
Changes the protection level.
|
void |
setProtocol(java.lang.String value)
Sets TLS/SSL protocol name.
|
void |
setProxyAuthentication(java.lang.String proxyUsername,
java.lang.String proxyPassword)
Sets the username and password to use when for authentication with
proxy server.
|
void |
setProxyHost(java.lang.String proxyHostname,
int proxyPort)
Sets the proxy hostname and port for this FTPS connection.
|
void |
setProxyType(java.lang.String proxyType)
Sets the proxy type will be used for this FTPS connection.
|
void |
setReceiveBufferSize(int receiveBufferSize)
Sets the receive buffer size option of the ftps connection.
|
void |
setSendBufferSize(int sendBufferSize)
Sets the send buffer size option of the ftps connection.
|
void |
setServerCertificates(java.security.KeyStore keystore)
Sets optional server certificate to be used during authentication.
|
void |
setServerCertificates(java.lang.String filename,
java.lang.String password)
Sets optional server certificate to be used during authentication.
|
void |
setServerCertificates(java.lang.String filename,
java.lang.String password,
java.lang.String storetype)
Sets optional server certificate to be used during authentication.
|
void |
setShutdownCCC(boolean shutdownCCC)
Sets whether SSL connection should be shutdown after successfully issuing
CCC command.
|
void |
setSslHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener value) |
void |
setTcpNoDelay(boolean value) |
void |
setTimeout(int timeout)
Sets the timeout for opening connection to FTP server.
|
void |
setTimezone(java.util.TimeZone timeZone)
Set the timezone.
|
void |
setUseEPRT(boolean value)
Sets whether to use EPRT or PORT command for data tranfers.
|
void |
setUseEPSV(boolean useEPSV)
Sets whether to use EPSV or PASV command for data tranfers.
|
void |
setUsername(java.lang.String user)
Sets username of FTP user.
|
void |
setWireEncoding(java.lang.String encoding)
Sets character set used when issuing commands and transferring files in ASCII mode.
|
void |
upload(byte[] data,
java.lang.String remoteFile)
Uploads file to FTP server where contents of file is not on disk but
in memory.
|
void |
upload(byte[] data,
java.lang.String remoteFile,
boolean append)
Uploads file to FTP server where contents of file is not on disk but
in memory.
|
void |
upload(java.io.File localFile)
Uploads file to FTP server.
|
void |
upload(java.io.File localFile,
boolean append)
Uploads file to FTP server.
|
void |
upload(java.io.File localFile,
java.lang.String remoteFile)
Uploads file to FTP server.
|
void |
upload(java.io.File localFile,
java.lang.String remoteFile,
boolean append)
Uploads file to FTP server.
|
void |
upload(java.io.InputStream input,
java.lang.String remoteFile)
Uploads contents of
InputStream to FTP server. |
void |
upload(java.io.InputStream input,
java.lang.String remoteFile,
boolean append)
Uploads contents of
InputStream to FTP server. |
void |
upload(java.lang.String localFile)
Uploads file to FTP server.
|
void |
upload(java.lang.String localFile,
boolean append)
Uploads file to FTP server.
|
void |
upload(java.lang.String extension,
java.io.File localFile)
Uploads file to FTP server using temporary extension, then renames file back to original name once uploaded.
|
void |
upload(java.lang.String localFile,
java.lang.String remoteFile)
Uploads file to FTP server.
|
void |
upload(java.lang.String localFile,
java.lang.String remoteFile,
boolean append)
Uploads file to FTP server.
|
void |
uploadDir(java.io.File localDir)
Uploads local directory and contents recursively to FTP server.
|
void |
uploadDir(java.io.File localDir,
int retryLimit,
boolean performChecksum)
Uploads local directory and contents to FTP server.
|
void |
uploadDir(java.io.File localDir,
int retryLimit,
boolean performChecksum,
java.lang.String extension)
Uploads local directory and contents to FTP server.
|
void |
uploadDir(java.io.File localDir,
int retryLimit,
boolean performChecksum,
java.lang.String extension,
int threadCount)
Uploads local directory and contents to FTP server.
|
void |
uploadDir(java.io.File localDir,
int retryLimit,
int retryInterval,
boolean performChecksum,
java.lang.String extension)
Uploads local directory and contents to FTP server.
|
void |
uploadDir(java.io.File localDir,
int retryLimit,
int retryInterval,
boolean performChecksum,
java.lang.String extension,
int threadCount)
Uploads local directory and contents to FTP server.
|
void |
uploadDir(java.io.File localDir,
java.lang.String extension)
Uploads local directory and contents recursively to FTP server.
|
java.lang.String |
uploadUnique(java.io.File file)
Uploads the file which is created in the current directory
under a name unique to that directory.
|
java.lang.String |
uploadUnique(java.io.File file,
boolean useFilenameAsSeed)
Uploads the file which is created in the current directory
under a name unique to that directory.
|
java.lang.String |
uploadUnique(java.io.InputStream in,
java.lang.String fileName)
Uploads the file which is created in the current directory
under a name unique to that directory.
|
java.lang.String |
uploadUnique(java.lang.String fileName)
Uploads the file which is created in the current directory under a name
unique to that directory.
|
java.lang.String |
uploadUnique(java.lang.String fileName,
boolean useFilenameAsSeed)
Uploads the file which is created in the current directory under a name
unique to that directory.
|
public static final int AUTO
getMode()
,
Constant Field Valuespublic static final int ASCII
getMode()
,
Constant Field Valuespublic static final int BINARY
getMode()
,
Constant Field Valuespublic static final java.lang.String CURRENT_DIR
public static final java.lang.String UP_DIR
public static final Ftps.ConnectionStrategy IMPLICIT_SSL
public static final Ftps.ConnectionStrategy AUTH_TLS
public static final Ftps.ConnectionStrategy AUTH_SSL
public Ftps()
public Ftps(java.lang.String host, java.lang.String user, java.lang.String pwd)
host
- the hostname of FTP serveruser
- the username of FTP userpwd
- the password of FTP usZerpublic Ftps(java.lang.String host, java.lang.String user, java.lang.String pwd, java.lang.String account)
host
- the hostname of FTP serveruser
- the username of FTP userpwd
- the password of FTP useraccount
- the optional account of FTP user or null
if not neededpublic Ftps(java.lang.String host, java.lang.String user, java.lang.String pwd, int port)
host
- the hostname of FTP serveruser
- the username of FTP userpwd
- the password of FTP userport
- the port of FTP serverpublic Ftps(java.lang.String host, java.lang.String user, java.lang.String pwd, java.io.File localDirectory)
host
- the hostname of FTP serveruser
- the username of FTP userpwd
- the password of FTP userlocalDirectory
- the local directory to be used for uploading
/ downloading filespublic void setTimezone(java.util.TimeZone timeZone)
timeZone
- public java.util.TimeZone getTimeZone()
public void setPreserveDownloadTimestamp(boolean value)
value
- public boolean getPreserveDownloadTimestamp()
public boolean getPreserveUploadTimestamp()
public void setPreserveUploadTimestamp(boolean value)
value
- - boolean valuepublic void setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)
#clearProxySettings
method.proxyUsername
- the proxy usernameproxyPassword
- the proxy passwordclearProxySettings()
public void setAutoDetectIpv6(boolean value)
value
- public boolean getAutoDetectIpv6()
public java.lang.String getProxyUsername()
public java.lang.String getProxyPassword()
public java.lang.String getProxyHostname()
public int getProxyPort()
public void setProxyHost(java.lang.String proxyHostname, int proxyPort)
#clearProxySettings
method.proxyHostname
- the hostname or ip address of the proxy serverproxyPort
- the port of the proxy serverclearProxySettings()
public void setProxyType(java.lang.String proxyType)
proxyType
- The proxy type. Valid values: HTTP, SOCKS5public java.lang.String getProxyType()
public void clearProxySettings()
public void setAscii() throws FtpException
FtpException
- if an I/O or FTP error occurs.public void setAuto(boolean auto) throws FtpException
auto
- true
to turn automatic detect on
false
to turn offFtpException
- if an I/O or Ftp related error occurspublic void setBinary() throws FtpException
FtpException
- if an I/O or FTP error occurs.public void setBlockTransferSize(int blockSize)
blockSize
- the block size in bytespublic int getBlockTransferSize()
@Deprecated public void setCharacterEncoding(java.lang.String encoding)
encoding
- the character encoding to be used@Deprecated public java.lang.String getCharacterEncoding()
public void setCompression(boolean compression)
compression
- Compression indicator.public boolean getCompression()
true
data will be compressed, false
otherwise.public void setClientCertificates(java.security.KeyStore keystore, java.lang.String password) throws FtpException
keystore
- the JKS keystore containing certificatespassword
- the password for opening JKS keystoreFtpException
- if an error occurs opening keystorepublic void setClientCertificates(java.lang.String filename, java.lang.String password) throws FtpException
keytool
utility provided in the Sun JDK.
Example:
keytool.exe -import -file x509.cer -keystore your_store_nameThe example above imports the certificate x509.cer into a keystore named your_store_name
filename
- the keystore file containing the client certificatepassword
- the keystore passwordFtpException
- if an I/O error occurspublic void setClientCertificates(java.lang.String filename, java.lang.String password, java.lang.String storetype) throws FtpException
keytool
utility provided in the Sun JDK.
Example:
keytool.exe -import -file x509.cer -keystore your_store_nameThe example above imports the certificate x509.cer into a keystore named your_store_name
filename
- the keystore file containing the client certificatepassword
- the keystore passwordstoretype
- the keystore type valid values include jks and pkcs12FtpException
- if an I/O error occurspublic void setConnectBeforeCommand(boolean value)
value
- true
if should connect before sending data transfer command, false
otherwise
send the command in passive modepublic boolean getConnectBeforeCommand()
true
if should connect before sending data transfer command, false
otherwisepublic boolean isConnected()
false
will be returned and an FtpConnectionLostEvent
will be fired to any subscribed FtpListener
.true
if connected false
otherwiseFtpConnectionLostEvent
public void setConnectionType(Ftps.ConnectionStrategy connectionType)
Ftps.AUTH_TLS
.connectionType
- the current connection typepublic Ftps.ConnectionStrategy getConnectionType()
Ftps.AUTH_TLS
.public void setContext(javax.net.ssl.SSLContext context)
context
- the new SSL contextSSLContext
public java.util.LinkedList getListeners()
public void setListeners(java.util.LinkedList listeners)
listeners
- public void setProtocol(java.lang.String value)
value
- a protocol namepublic void setContextKeystoreProvider(java.lang.String provider)
provider
- The providerpublic void setContextProtocolProvider(java.lang.String provider)
provider
- the providerpublic void setContextAlgorithmProvider(java.lang.String provider)
provider
- the providerpublic java.lang.String getContextAlgorithmProvider()
public java.lang.String getContextKeystoreProvider()
null
.public java.lang.String getContextProtocolProvider()
null
.public void setContextAlgorithm(java.lang.String algorithm)
algorithm
- the algorithmpublic java.lang.String getContextAlgorithm()
public void setContextProtocol(java.lang.String protocol)
protocol
- the protocolpublic java.lang.String getContextProtocol()
public javax.net.ssl.SSLContext getContext()
SSLContext
@Deprecated public void setDataPort(int dataPort)
dataPort
- active port@Deprecated public int getDataPort()
public int getDataPortEnd()
public void setDataPortRange(int dataPortStart, int dataPortEnd)
dataPortStart
- start data port range for incoming connectionsdataPortEnd
- end data port range for incoming connectionspublic int getDataPortStart()
public void setDebug(boolean debug)
System.out
.debug
- true
to turn debugging onsetDebugStream(java.io.PrintStream)
public boolean getDebug()
true
if debugging is onpublic void setDebugStream(java.io.PrintStream debugStream)
PrintStream
is System.out
debugStream
- the PrintStream
to send debug statements toPrintStream
public java.io.PrintStream getDebugStream()
PrintStream
is System.out
.PrintStream
used in reporting debug statementsPrintStream
public void setDir(java.lang.String remoteDirectory) throws FtpException
remoteDirectory
- the remote directoryFtpException
- if an I/O or FTP error occurs.public java.lang.String getDir() throws FtpException
FtpException
- if an I/O or FTP error occurs.public java.util.Enumeration getDirListing(java.lang.String filter) throws FtpException
getDirListingRegex
method which uses regular expressions to parse results of a directory listing.
Parsers are included to handle UNIX, NT and VMS directory style listings.
If you are connecting to a FTP server that does not use any of these listing formats
then you can optionally develop your own parser by extending the FtpFileParser
class,
or use some of the alternative methods for obtaining a directory listing such
as the getNameListing
or getDirListingAsString
methods.filter
- the regular expression filename filterEnumeration
of FtpFile
objectsFtpException
- if an I/O or FTP error occurs.FtpFile
,
getDirListingAsString(String)
,
getDirListingRegex(String)
,
getNameListing(java.lang.String)
,
FtpFileParser
,
UnixParser
,
NTParser
,
VMSParser
public java.util.Enumeration getDirListing() throws FtpException
FtpFileParser
class,
or use some of the alternative methods for obtaining a directory listing such
as the getNameListing
or getDirListingAsString
methods.Enumeration
of FtpFile
objectsFtpException
- if an I/O or FTP error occurs.FtpFile
,
getDirListingAsString(String)
,
getNameListing(java.lang.String)
,
FtpFileParser
,
UnixParser
,
NTParser
,
VMSParser
public java.lang.String getDirListingAsString(java.lang.String filter) throws FtpException
getDirListingRegex
method which uses regular expressions to parse results of a directory listing.filter
- a regular expression filename filterFtpException
- if an I/O or FTP error occurs.getDirListingRegex(String)
public java.util.Enumeration getDirListingRegex(java.lang.String filter) throws FtpException
filter
- regular expression used to obtain the file listFtpException
- if an I/O or protocol error occurs.public java.lang.String getDirListingRegexAsString(java.lang.String filter) throws FtpException
filter
- regular expression used to obtain the file listString
FtpException
- if an I/O or protocol error occurs.public java.lang.String getDirListingAsString() throws FtpException
FtpException
- if an I/O or FTP error occurs.public void setDirUp() throws FtpException
FtpException
- if an I/O or FTP error occurs.public void setDiskEncoding(java.lang.String encoding)
encoding
- the character encoding to be usedpublic java.lang.String getDiskEncoding()
public void setEnabledCiphers(java.lang.String[] enabledCiphers)
enabledCiphers
- enabled SSL cipher suites or null
for using
system-default cipher suites setpublic java.lang.String[] getEnabledCiphers()
null
if system-default cipher suites are usedpublic void setErrorOnSizeCommand(boolean error)
false
.error
- true
if exception should be thrown, false
otherwisepublic boolean getErrorOnSizeCommand()
false
.true
if exception is thrown when SIZE command is not supported
an exception when it caused an error, false
the error will be ignored.public boolean isFeatureSupported(java.lang.String command)
command
- The feature will be searchedtrue
if the command is found into the server feature list;
false
otherwisepublic java.util.Enumeration getFeatures() throws FtpException
Enumeration
of features stringsFtpException
- if an error occurspublic void setFileModificationTime(java.lang.String remoteName, java.util.Date date) throws FtpException
remoteName
- File will be modified its modification time.date
- The new modification timeFtpException
- If an error occurspublic void setFileCreationTime(java.lang.String remoteName, java.util.Date date) throws FtpException
remoteName
- File will be modified its creation time.date
- The new creation timeFtpException
- If an error occurs.public void setFileTimestamp(java.lang.String remoteName, java.util.Date dateFile) throws FtpException
remoteName
- the remote filedateFile
- the date/timestamp of remote fileFtpException
- if an I/O or FTP error occurs.public java.util.Date getFileTimestamp(java.lang.String remoteFile) throws FtpException
remoteFile
- the remote fileFtpException
- if an I/O or FTP error occurs.public long getFilesize(java.lang.String remoteFile) throws FtpException
remoteFile
- the remote fileFtpException
- if an I/O or FTP error occurs.public void setFtpFileParser(FtpFileParser parser)
FtpFileParser
used to parse directory listing returned when
invoking Ftps#getDirListing
method. If FtpFileParser
is null
upon
establishing connection the Ftps
class will attempt to determine the proper
FtpFileParser
based on information retrieved from the FTP server.
If the FtpFileParser
is null
and cannot be determined otherwise then
by default an instance of UnixParser
will be used.
Upon disconnecting from FTP server the FtpFileParser
will be reset to null
.parser
- a FtpFileParser
instanceFtpFileParser
,
UnixParser
,
NTParser
,
VMSParser
public FtpFileParser getFtpFileParser()
FtpFileParser
used to parse directory listing returned when
invoking Ftp#getDirListing
method. If FtpFileParser
is null
upon
establishing connection the Ftps
class will attempt to determine the proper
FtpFileParser
based on information retrieved from the FTP server.
If the FtpFileParser
is null
and cannot be determined then
by default an instance of UnixParser
will be used.
Upon disconnecting from FTP server the FtpFileParser
will be reset to null
.FtpFileParser
or null
if no FtpFileParser
has been defined.FtpFileParser
,
UnixParser
,
NTParser
,
VMSParser
public void setHostname(java.lang.String host)
host
- the hostname or IP address of FTP serverpublic void setHostname(java.lang.String host, boolean ensureConnected)
host
- ensureConnected
- public java.lang.String getHostname()
public java.io.InputStream getInputStream(java.lang.String remoteFile, long offset) throws java.io.IOException
InputStream
from FTP server for the purposes of downloading a file.remoteFile
- remote file name to downloadoffset
- file offsetInputStream
java.io.IOException
- if an I/O or FTP error occurs.public void setLinger(int linger)
linger
- the linger value in millisecondspublic int getLinger()
public void setLocalDir(java.io.File localDirectory)
localDirectory
- the local directorypublic java.io.File getLocalDir()
public java.util.Enumeration getLocalDirListing()
Enumeration
of File
public java.util.Enumeration getMachineDirListing(java.lang.String dirname, java.lang.String filter) throws FtpException
dirname
- directory name or an empty String
for current directoryfilter
- a regular expression e.g. ".*\\.txt" for all files ending in .txt extensionEnumeration
of FtpFile
FtpException
- if an I/O or FTP error occursFtpFile
public java.util.Enumeration getMachineDirListing(java.lang.String dirname) throws FtpException
dirname
- the directory name or an empty String
to use current directoryEnumeration
of FtpFile
FtpException
- if an I/O or FTP error occurspublic FtpFile getMachineFileListing(java.lang.String filename) throws FtpException
filename
- target filename or an empty String
for current diectoryFtpFile
FtpException
- if an error occursFtpFile
public int getMode()
Ftps.AUTO
where 0 = Ftps.AUTO
, 1 = Ftps.ASCII
, 2 = Ftp.BINARY
public java.util.Enumeration getNameListing(java.lang.String filter) throws FtpException
filter
- the filename filterEnumeration
of String
where each item represents a file
or directory nameFtpException
- if an I/O or FTP related error occurspublic java.util.Enumeration getNameListing() throws FtpException
Enumeration
of String
where each item represents a file
or directory nameFtpException
- if an I/O or FTP related error occurspublic java.io.OutputStream getOutputStream(java.lang.String fileName, long off, boolean append) throws java.io.IOException
OutputStream
from FTP server for the purposes of uploading a file.fileName
- the remote filename to store file asoff
- file offsetappend
- true
to append to remote file on FTP server, false
otherwiseOutputStream
java.io.IOException
- if an FTP error occurs.public void setNATAddress(java.lang.String ipAddress) throws FtpException
setPortAddress
and setDataPortRange
methods.ipAddress
- the IP address of NAT serverFtpException
- if an I/O or FTP error occurssetDataPortRange(int, int)
,
setPortAddress(String)
public java.lang.String getNATAddress() throws FtpException
FtpException
public javax.net.ssl.HandshakeCompletedListener getSslHandshakeCompletedListener()
public void setSslHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener value)
public void setPassive(boolean passive)
true
.passive
- true
to use passive transfer, false
otherwisepublic boolean getPassive()
true
.true
if passive mode is enabled, false
otherwisepublic void setPassword(java.lang.String password)
password
- the password of FTP userpublic java.lang.String getPassword()
public void setPort(int port)
port
- the port of FTP serverpublic int getPort()
public void setPortAddress(java.lang.String string)
string
- an IP addresspublic java.lang.String getPortAddress()
public void setProtectionLevel(char level) throws FtpException
level
- a protection level of P (private) or C (Clear)FtpException
- if a FTP or I/O related error occurspublic int getResponseCode()
public void setSendBufferSize(int sendBufferSize)
sendBufferSize
- Send buffer size.public void setReceiveBufferSize(int receiveBufferSize)
receiveBufferSize
- Receive buffer size.public void setServerCertificates(java.security.KeyStore keystore) throws FtpException
keystore
- the keystore containing server certificateFtpException
- if an error occurs reading keystorepublic void setServerCertificates(java.lang.String filename, java.lang.String password) throws FtpException
keytool
utility provided in the Sun JDK.
Example:
keytool.exe -import -file x509.cer -keystore your_store_nameThe example above imports the certificate x509.cer into a keystore named your_store_name
filename
- the keystore file containing the server certificatepassword
- the keystore passwordFtpException
- if an I/O error occurspublic void setServerCertificates(java.lang.String filename, java.lang.String password, java.lang.String storetype) throws FtpException
keytool
utility provided in the Sun JDK.
Example:
keytool.exe -import -file x509.cer -keystore your_store_nameThe example above imports the certificate x509.cer into a keystore named your_store_name
filename
- the keystore file containing the server certificatepassword
- the keystore passwordstoretype
- the keystore type valid values include jks and pkcs12FtpException
- if an I/O error occurspublic void setShutdownCCC(boolean shutdownCCC)
true
.shutdownCCC
- true
to shutdown, false
otherwisepublic boolean getShutdownCCC()
true
.true
to shutdown, false
otherwisepublic java.lang.String getSystemType() throws FtpException
FtpException
- if an I/O or FTP error occurs.public void setTimeout(int timeout)
timeout
- the timeout in millisecondspublic int getTimeout()
public boolean getTcpNoDelay()
public void setTcpNoDelay(boolean value)
public void setUsername(java.lang.String user)
user
- the username of FTP userpublic java.lang.String getUsername()
public void setUseEPSV(boolean useEPSV)
useEPSV
- true
to use EPSV command, false
to use PASV command.public boolean getUseEPSV()
false
, meaning PASV command will be used.true
to use EPSV command, false
to use PASV command.public void setUseEPRT(boolean value)
value
- true
to use EPSV command, false
to use PASV command.public boolean getUseEPRT()
false
, meaning PORT command will be used.true
to use EPRT command, false
to use PORT command.public void setWireEncoding(java.lang.String encoding)
encoding
- the character encoding to be usedpublic java.lang.String getWireEncoding()
@Deprecated public void addFtpsCertificateVerifier(FtpsCertificateVerifier listener)
setFtpsCertificateVerifier(FtpsCertificateVerifier)
listener
- the listener to addFtpsCertificateVerifier
public void setFtpsCertificateVerifier(FtpsCertificateVerifier listener)
listener
- the listener to addFtpsCertificateVerifier
public FtpsCertificateVerifier getFtpsCertificateVerifier()
FtpsCertificateVerifier
public void addFtpListener(FtpListener listener)
listener
- the listener to addFtpListener
public void changePassword(java.lang.String oldPassword, java.lang.String newPassword) throws FtpException
oldPassword
- The old password.newPassword
- The new password.FtpException
- FtpException if underlayed I/O or FTP error occurs.public boolean checksum(java.io.File localfile, java.lang.String remoteFile) throws FtpException
localfile
- local fileremoteFile
- remote filetrue
if checksums are equal;
false
otherwiseFtpException
- if an error occurspublic boolean checksum(byte[] data, java.lang.String remoteFile) throws FtpException
data
- dataremoteFile
- remote filetrue
if checksum are equal;
false
otherwiseFtpException
- if an error occurspublic void clearCommandChannel() throws FtpException
FtpException
- if an I/O error occurspublic Ftps connect() throws FtpException
FtpException
- if an I/O or FTP error occurs.setUsername(java.lang.String)
,
setPassword(java.lang.String)
,
setAccount(String)
public Ftps connect(boolean login) throws FtpException
login
- true to login false otherwiseFtpException
- if an I/O or FTP error occurspublic boolean getServerFeaturesCommandSuccessful()
public void deleteDir(java.lang.String remoteDirectory, boolean recurse) throws FtpException
recurse
parameter will be used to determine if files and subdirectories within
directory should be removed.remoteDirectory
- the directory to removerecurse
- true
if it should delete files and
subdirectories within directoryFtpException
- if an I/O or FTP error occurs.public void deleteDir(java.lang.String remoteDirectory) throws FtpException
remoteDirectory
- the directory to removeFtpException
- if an I/O or FTP error occurs.public void deleteFile(java.lang.String remoteFile) throws FtpException
remoteFile
- name of file to deleteFtpException
- if an I/O or FTP error occurs.public void disconnect()
public void close()
close
in interface java.lang.AutoCloseable
public void download(java.io.OutputStream out, java.lang.String remoteFile) throws FtpException
OutputStream
.
Closure of OutputStream
is responsibility of programmer.out
- the OutputStream
to write download toremoteFile
- remote filenameFtpException
- if an I/O or FTP error occurs.public java.io.File download(java.lang.String localFile, java.lang.String remoteFile) throws FtpException
localFile
- destination filename relative to current local directory, NOT an absolute pathremoteFile
- remote filenameFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public java.io.File download(java.lang.String remoteFile) throws FtpException
remoteFile
- the file to downloadFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void downloadDir(java.lang.String remoteDir) throws FtpException
remoteDir
- the directory to downloadFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void downloadDir(java.lang.String remoteDir, int retryLimit, boolean performChecksum) throws FtpException
remoteDir
- the remote directory to downloadretryLimit
- the retry limit if download failsperformChecksum
- whether to perform checksum on files downloaded, not supported by all FTP serversFtpException
- if an I/O or FTP error occurs.public void downloadDir(java.lang.String remoteDir, int retryLimit, int retryInterval, boolean performChecksum) throws FtpException
remoteDir
- the remote directory to downloadretryLimit
- the retry limit if download failsretryInterval
- the retry interval in secondsperformChecksum
- whether to perform checksum on files downloaded, not supported by all FTP serversFtpException
- if an I/O or FTP error occurs.public void downloadDir(java.lang.String remoteDir, int retryLimit, boolean performChecksum, int threadCount) throws FtpException
remoteDir
- retryLimit
- performChecksum
- threadCount
- FtpException
public void downloadDir(java.lang.String remoteDir, int retryLimit, int retryInterval, boolean performChecksum, int threadCount) throws FtpException
remoteDir
- the directory to downloadretryLimit
- retry limit if an error occursperformChecksum
- whether to perform checksum after each download, not supported by all FTP serversFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void abortDownloadThreads()
public void abortDownloadThread(java.lang.String file)
file
- public void interrupt()
true
.
After invoking this method you must reset the interrupted flag to false
before transferring any files.reset()
public boolean interrupted()
true
if transfer process was interrupted.public java.lang.String issueCommand(java.lang.String cmd) throws FtpException
cmd
- the command to issueFtpException
- if an I/O or FTP error occurspublic java.lang.String issueCommandCheck(java.lang.String cmd) throws FtpException
cmd
- the command to issueFtpException
- if an I/O or FTP error occurspublic void login() throws FtpException
Ftps#connect
.FtpException
- if an I/O or FTP error occursconnect()
public void makeDir(java.lang.String newDirectory) throws FtpException
newDirectory
- name of directory to makeFtpException
- if an I/O or FTP error occurs.public void makeDirRecursive(java.lang.String newDirectory) throws FtpException
newDirectory
- full path of directory to makeFtpException
- if an I/O or FTP error occurspublic java.io.File makeLocalDir(java.lang.String directoryName)
directoryName
- name of directorygetLocalDir()
public void mdelete(java.lang.String filter) throws FtpException
filter
- the regular expression filter to useFtpException
- if an I/O or FTP error occurs.public void mdownload(java.util.Enumeration fileNames) throws FtpException
downloadDir(String)
method instead.
Downloads are stored relative to current local directory.fileNames
- filenames of files to downloadFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
,
downloadDir(String)
public void mdownload(java.lang.String filter) throws FtpException
filter
- the regular expression filter to useFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
,
downloadDir(java.lang.String)
public void mupload(java.util.Enumeration fileNames) throws FtpException
fileNames
- filenames of files to uploadFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void mupload(java.lang.String filter) throws FtpException
filter
- the regular expression filter to useFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public java.lang.String noop() throws FtpException
FtpException
- if an I/O or FTP error occurspublic java.lang.String readResponse() throws FtpException
FtpException
- if an I/O or FTP related error occurs.public void removeFtpListener(FtpListener listener)
listener
- the listener to removeFtpListener
public void renameFile(java.lang.String remoteFile, java.lang.String newFile) throws FtpException
remoteFile
- name of file to renamenewFile
- new name of fileFtpException
- if an I/O or FTP error occurs.public void reset()
false
.
This method should be invoked if you have interrupted a transfer using the
Ftps#interrupt
method and wish to resume transfering files.interrupt()
public java.io.File resumeDownload(java.lang.String remoteFile, long off) throws FtpException
remoteFile
- the file to downloadoff
- file offset in bytesFtpException
- if an I/O or FTP error occurs.public java.io.File resumeDownload(java.lang.String localFile, java.lang.String remoteFile, long off) throws FtpException
localFile
- local file nameremoteFile
- the file to downloadoff
- file offset in bytesFtpException
- if an I/O or FTP error occurs.public void resumeUpload(java.io.File localFile, long off) throws FtpException
localFile
- the local file to uploadoff
- file offset in bytesFtpException
- if an I/O or FTP error occurs.public void resumeUpload(java.io.File localFile, java.lang.String remoteFile, long off) throws FtpException
localFile
- the local file to uploadremoteFile
- the destination file on FTP serveroff
- the local file offset in bytesFtpException
- if an I/O or FTP related error occurspublic void resumeUpload(java.lang.String localFile, long off) throws FtpException
localFile
- the local file to uploadoff
- file offset in bytesFtpException
- if an I/O or FTP error occurs.public void resumeUpload(java.lang.String localFile, java.lang.String remoteFile, long off) throws FtpException
localFile
- the local file to uploadremoteFile
- the remote destination file on FTP serveroff
- the local file offset in bytesFtpException
- if an I/O or FTP related error occurspublic void upload(java.io.File localFile, java.lang.String remoteFile, boolean append) throws FtpException
localFile
is a directory then directory and entire contents are uploaded.localFile
- the local file to uploadremoteFile
- the destination of uploadappend
- true
to append to remote file on FTP server,
false
otherwiseFtpException
- if an I/O or FTP related error occurspublic void upload(java.io.File localFile, boolean append) throws FtpException
localFile
is a directory then directory and entire contents are uploaded.localFile
- the local file to uploadappend
- true
to append to remote file on FTP server,
false
otherwiseFtpException
- if an I/O or FTP related error occurspublic void upload(java.io.File localFile, java.lang.String remoteFile) throws FtpException
localFile
is a directory then directory and entire contents are uploaded.localFile
- the local file to uploadremoteFile
- the destination of uploadFtpException
- if an I/O or FTP related error occurspublic void upload(java.io.File localFile) throws FtpException
localFile
is a directory then directory and entire contents are uploaded.localFile
- the local file to uploadFtpException
- if an I/O or FTP related error occurspublic void upload(java.lang.String extension, java.io.File localFile) throws FtpException
extension
- the temporary extension to use when uploading files prior to renaming them or null
to use default extensionlocalFile
- the local file to uploadFtpException
- if an I/O or FTP related error occurspublic void upload(java.lang.String localFile, java.lang.String remoteFile, boolean append) throws FtpException
localFile
- the local file to uploadremoteFile
- the destination filename of uploadappend
- true
to append to remote file on FTP server,
false
otherwiseFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void upload(java.lang.String localFile, java.lang.String remoteFile) throws FtpException
localFile
- the local file to uploadremoteFile
- the destination filename of uploadFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void upload(java.lang.String localFile, boolean append) throws FtpException
localFile
- the local file to uploadappend
- true
to append to remote file on FTP server,
false
otherwiseFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void upload(java.lang.String localFile) throws FtpException
localFile
- the local file to uploadFtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void upload(byte[] data, java.lang.String remoteFile, boolean append) throws FtpException
data
- the raw contents of the file to uploadremoteFile
- the filename to store file as on FTP serverappend
- true
to append to remote file on FTP server,
false
otherwiseFtpException
- if an I/O or FTP related error occurspublic void upload(byte[] data, java.lang.String remoteFile) throws FtpException
data
- the raw contents of the file to uploadremoteFile
- the filename to store file as on FTP serverFtpException
- if an I/O or FTP related error occurspublic void upload(java.io.InputStream input, java.lang.String remoteFile, boolean append) throws FtpException
InputStream
to FTP server.input
- the InputStream
to read fromremoteFile
- the destination of uploadappend
- true
if to append to remote destination, false
otherwiseFtpException
- if an I/O or FTP error occurs.public void upload(java.io.InputStream input, java.lang.String remoteFile) throws FtpException
InputStream
to FTP server.input
- the InputStream
to read fromremoteFile
- the destination of uploadFtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir) throws FtpException
localDir
- the directory to uploadFtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir, java.lang.String extension) throws FtpException
localDir
- the directory to uploadextension
- the temporary extension to use when uploading files prior to renaming them or null
to use default extensionFtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir, int retryLimit, boolean performChecksum) throws FtpException
localDir
- the directory to uploadretryLimit
- retry limit if upload failsperformChecksum
- whether to perform checksum after upload, not supported by all FTP serversFtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir, int retryLimit, boolean performChecksum, java.lang.String extension) throws FtpException
localDir
- the directory to uploadretryLimit
- retry limit if upload failsperformChecksum
- whether to perform checksum, not supported by all FTP serversextension
- the temporary extension to use prior to renaming files after uploadFtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir, int retryLimit, boolean performChecksum, java.lang.String extension, int threadCount) throws FtpException
localDir
- the directory to uploadretryLimit
- retry limit if upload failsperformChecksum
- whether to perform checksum, not supported by all FTP serversextension
- the temporary extension to use prior to renaming files after uploadthreadCount
- the thread countFtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir, int retryLimit, int retryInterval, boolean performChecksum, java.lang.String extension, int threadCount) throws FtpException
localDir
- the directory to uploadretryLimit
- the retry limit if upload failsperformChecksum
- whether to perform checksum after each upload, not supported by all FTP serversextension
- the temporary extension to use before renaming files or null
to use default extensionthreadCount
- the number of threads to use for transferring filesFtpException
- if an I/O or FTP error occurs.public void abortUploadThread(java.lang.String file)
file
- public void abortUploadThreads()
public int getRecursiveDirectoryFileCount(java.lang.String directory)
directory
- - the remote directory namepublic long getRecursiveDirectorySize(java.lang.String directory)
directory
- - the remote directory namepublic void uploadDir(java.io.File localDir, int retryLimit, int retryInterval, boolean performChecksum, java.lang.String extension) throws FtpException
localDir
- the directory to uploadretryLimit
- retry limit if upload failsretryInterval
- the retry interval in secondsperformChecksum
- whether to perform checksum, not supported by all FTP serversextension
- the temporary extension to use prior to renaming files after uploadFtpException
- if an I/O or FTP error occurs.public java.lang.String uploadUnique(java.lang.String fileName) throws FtpException
fileName
- the filename to uploadFtpException
- if an I/O or FTP error occurspublic java.lang.String uploadUnique(java.lang.String fileName, boolean useFilenameAsSeed) throws FtpException
fileName
- the filename to uploaduseFilenameAsSeed
- whether filename should be used as seed value for generating unique filename on serverFtpException
- if an I/O or FTP error occurspublic java.lang.String uploadUnique(java.io.File file) throws FtpException
file
- the file to uploadFtpException
- if an I/O or FTP error occurspublic java.lang.String uploadUnique(java.io.File file, boolean useFilenameAsSeed) throws FtpException
file
- the file to uploaduseFilenameAsSeed
- whether filename should be used as seed value for generating unique filename on serverFtpException
- if an I/O or FTP error occurspublic java.lang.String uploadUnique(java.io.InputStream in, java.lang.String fileName) throws FtpException
in
- data input stream.fileName
- the filename seed to use for determining remote filename or null
not to pass filename as part of STOU commandFtpException
- if an I/O or FTP error occurspublic java.lang.String getLocalChecksum(java.io.File localFile) throws FtpException
localFile
- the file used to calculate local checksumFtpException
- if an error occurspublic java.lang.String getRemoteFileChecksum(java.lang.String remoteFile) throws FtpException
remoteFile
- remote fileFtpException
- if an error occurspublic java.util.Vector getRemoteFileList(java.lang.String remoteDir) throws FtpException
remoteDir
- The current remote will be consultedFtpException
- If an error occurspublic java.lang.String getAccount()
setUsername(String)
public void setAccount(java.lang.String account)
account
- the optional FTP accountgetUsername()
Copyright © JSCAPE LLC. 1999-2023. All Rights Reserved