public class FtpsTransfer extends java.lang.Object implements FileTransfer
// create new FtpsTransfer instance
FileTransfer ftp = new FtpsTransfer("ftp.myserver.com","anonymous","user@myserver.com");
try {
// connect to FTP server
ftp.connect();
<p/>
// print out directory listing
System.out.println(ftp.getDirListingAsString());
<p/>
// disconnect from FTP server
ftp.disconnect();
} catch(Exception e) {
System.out.println(e);
}
ASCII, AUTO, BINARY, CURRENT_DIRECTORY, PARENT_DIRECTORY| Constructor and Description |
|---|
FtpsTransfer()
Creates FtpsTransfer instance.
|
FtpsTransfer(java.lang.String host,
int port,
java.lang.String user,
java.lang.String password,
java.io.File localDirectory,
java.util.Set<FileTransferListener> listeners) |
FtpsTransfer(java.lang.String host,
java.lang.String user,
java.lang.String pwd)
Creates FtpsTransfer instance.
|
FtpsTransfer(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
java.io.File localDirectory)
Creates FtpsTransfer instance.
|
FtpsTransfer(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
int port)
Creates FtpsTransfer instance.
|
FtpsTransfer(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
java.lang.Integer port)
Method FtpsTransfer
|
| Modifier and Type | Method and Description |
|---|---|
void |
abortDownloadThread(java.lang.String remoteFile)
Abort download thread.
|
void |
abortDownloadThreads()
Abort all download threads.
|
void |
abortUploadThread(java.lang.String remoteFile)
Abort upload thread.
|
void |
abortUploadThreads()
Abort all upload threads.
|
void |
addFileTransferListener(FileTransferListener listener)
Adds FileTransferListener.
|
void |
addFtpsCertificateVerifier(FtpsCertificateVerifier listener)
Set certificate verifier handle acceptance of SSL certificate.
|
void |
changePassword(java.lang.String oldPassword,
java.lang.String newPassword)
Changes the password.
|
void |
checksum(java.io.File localFile,
java.lang.String remoteFile) |
void |
clearCommandChannel()
Clears command channel.
|
void |
clearProxySettings()
Clears proxy server values.
|
void |
close() |
FtpsTransfer |
connect()
Connects to server and performs login.
|
void |
connect(boolean login)
Establishes a connection with FTP server with optional login
|
FileTransfer |
copy()
Returns a copy of current transfer instance with same listeners.
|
void |
deleteDir(java.lang.String name)
Deletes directory from server.
|
void |
deleteDir(java.lang.String name,
boolean recursive)
Deletes directory from server.
|
void |
deleteFile(java.lang.String remoteFile)
Deletes remote file from server.
|
void |
disconnect()
Quits session and disconnects from server.
|
void |
download(java.io.OutputStream out,
java.lang.String remoteFile)
Downloads file from server and writes contents to provided
OutputStream. |
java.io.File |
download(java.lang.String remoteFile)
Downloads file from server.
|
java.io.File |
download(java.lang.String localFile,
java.lang.String remoteFile)
Downloads file from server.
|
void |
downloadDir(java.lang.String remoteDir)
Downloads remote directory and contents recursively from server.
|
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
boolean performChecksum)
Downloads remote directory and contents.
|
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
boolean performChecksum,
int threadCount)
Downloads remote directory and contents.
|
boolean |
exists(java.lang.String path)
Checks if the specified path exists on the remote server.
|
boolean |
getAutoDetectIpv6()
Get auto detect Ipv6.
|
int |
getBlockTransferSize()
Gets blocksize for use in transferring files.
|
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 server.
|
java.util.Enumeration<FileTransferRemoteFile> |
getDirListing()
Gets directory listing from server.
|
java.util.Enumeration<FileTransferRemoteFile> |
getDirListing(java.lang.String filter)
Gets file listing of files matching regular expression.
|
java.lang.String |
getDirListingAsString()
Gets directory listing of files on server.
|
java.lang.String |
getDirListingAsString(java.lang.String filter)
Gets file listing of files matching regular expression.
|
boolean |
getErrorOnSizeCommand()
Gets the error on size command indicator.
|
long |
getFilesize(java.lang.String remoteFile)
Gets filesize of remote file from server.
|
java.util.Date |
getFileTimestamp(java.lang.String remoteFile)
Gets date/timestamp of remote file from server.
|
java.lang.String |
getHostname()
Gets hostname of server.
|
java.lang.Object |
getImplementation()
Gets underlying file transfer instance.
|
java.io.InputStream |
getInputStream(java.lang.String remoteFile,
long pos)
Gets
InputStream for remote file for reading. |
java.lang.String |
getLocalChecksum(java.io.File localFile)
Returns local checksum.
|
java.io.File |
getLocalDir()
Gets local directory to be used in session.
|
java.util.Enumeration |
getLocalDirListing()
Gets local directory listing.
|
int |
getMode()
Gets data transfer mode for current session.
|
java.util.Enumeration |
getNameListing()
Gets directory listing of files on server.
|
java.util.Enumeration |
getNameListing(java.lang.String filter)
Gets directory listing of files on server matching regular expression.
|
java.io.OutputStream |
getOutputStream(java.lang.String fileName,
long off)
Gets
OutputStream for writing to remote file. |
boolean |
getPassive()
Gets whether passive mode is used for FTP connections.
|
java.lang.String |
getPassword()
Gets password.
|
boolean |
getPerformMLSDListing()
Get MLSD directory listing.
|
int |
getPort()
Gets server port.
|
int |
getRecursiveDirectoryFileCount(java.lang.String directory)
Get recursive directory file count.
|
long |
getRecursiveDirectorySize(java.lang.String directory)
Get recursive directory size.
|
java.lang.String |
getRemoteFileChecksum(java.lang.String remoteFile)
Returns remote file checksum.
|
java.util.Vector<FileTransferRemoteFile> |
getRemoteFileList(java.lang.String remoteDirectory)
Get remote directory list.
|
boolean |
getShutdownCCC()
Gets whether SSL connection should be shutdown after successfully issuing
CCC command.
|
boolean |
getTcpNoDelay() |
long |
getTimeout()
Gets the timeout for opening connection to server.
|
boolean |
getUseEPRT()
Gets use EPRT value.
|
boolean |
getUseEPSV()
Gets use EPSV value.
|
java.lang.String |
getUsername()
Gets username.
|
java.lang.String |
getWireEncoding()
Gets encoding set used when issuing commands and transferring files.
|
void |
interrupt()
See FileTransfer interface for method description.
|
boolean |
interrupted()
Checks if transfer process was interrupted.
|
boolean |
isChecksumVerificationRequired() |
boolean |
isConnected()
Checks if client is connected to server.
|
boolean |
isDirectory(java.lang.String remotePath) |
boolean |
isFeatureSupported(java.lang.String command) |
void |
issueCommand(java.lang.String command)
Issues command to the server.
|
void |
login()
Logs into FTP server after establishing a connection.
|
void |
makeDir(java.lang.String name)
Makes directory on server.
|
void |
makeDirRecursive(java.lang.String name)
Makes directory on server, creating subdirectories if necessary.
|
java.io.File |
makeLocalDir(java.lang.String name)
Creates local directory.
|
void |
mdelete(java.lang.String filter)
Deletes multiple files in servers current directory matching regular expression.
|
void |
mdownload(java.util.Enumeration fileNames)
Downloads specified files in current working remote directory from server
to local directory.
|
void |
mdownload(java.lang.String filter)
Downloads multiple files matching regular expression from server's current
directory.
|
void |
mupload(java.util.Enumeration fileNames)
Uploads multiple files to server.
|
void |
mupload(java.lang.String filter)
Uploads multiple files matching regular expression to server's current directory.
|
void |
removeFileTransferListener(FileTransferListener listener)
Removes specified FileTransferListener.
|
void |
renameFile(java.lang.String remoteFile,
java.lang.String newFile)
Renames remote file on server.
|
void |
reset()
Resets the interrupted flag to
false. |
void |
resumeDownload(java.io.OutputStream out,
java.lang.String remoteFile,
long remoteFileOffset) |
void |
resumeDownload(java.lang.String remoteFile,
long offset)
Resumes download of file from server.
|
void |
resumeDownload(java.lang.String localFile,
java.lang.String remoteFile,
long offset)
Resumes download of file from server.
|
void |
resumeUpload(java.io.File file,
long offset)
Resumes upload of file to server.
|
void |
resumeUpload(java.io.File localFile,
java.lang.String remoteFile,
long localFileOffset)
Resume upload of file to server.
|
void |
resumeUpload(java.io.InputStream in,
long length,
java.lang.String remoteFile,
long remoteFileOffset) |
void |
resumeUpload(java.lang.String file,
long offset)
Resumes upload of file to server.
|
boolean |
sameChecksum(java.io.File localFile,
java.lang.String remoteFile)
Checks a checksum equality of local and remote files.
|
FileTransfer |
setAscii()
Sets data transfer mode to ASCII.
|
FileTransfer |
setAuto(boolean auto)
Sets data transfer mode to automatically detect transfer mode.
|
FtpsTransfer |
setAutoDetectIpv6(boolean value)
Set auto detect Ipv6.
|
FileTransfer |
setBinary()
Sets data transfer mode to binary.
|
FileTransfer |
setBlockTransferSize(int blocksize)
Sets block size for use in transferring files.
|
FileTransfer |
setChecksumVerificationRequired(boolean value) |
FtpsTransfer |
setClientCertificates(java.security.KeyStore keystore,
java.lang.String password)
Sets optional client certificate keystore for use during authentication.
|
FtpsTransfer |
setClientCertificates(java.lang.String filename,
java.lang.String password)
Sets optional client certificate to be used during authentication.
|
FtpsTransfer |
setClientCertificates(java.lang.String filename,
java.lang.String password,
java.lang.String storetype)
Sets optional client certificate to be used during authentication.
|
FtpsTransfer |
setCompression(boolean compression)
Sets whether the data will be compressed during the transfering.
|
FtpsTransfer |
setConnectBeforeCommand(boolean before)
Sets the connectBefore property value
|
FileTransfer |
setDebug(boolean debug)
Sets debugging state.
|
FileTransfer |
setDebugStream(java.io.PrintStream ps)
Sets
PrintStream used in reporting debug statements. |
FileTransfer |
setDir(java.lang.String name)
Sets current directory on server.
|
FileTransfer |
setDirUp()
Sets current directory on server to parent directory.
|
FtpsTransfer |
setErrorOnSizeCommand(boolean error)
Sets the indicator value which will be used by methods that invokes
getFileSize.
|
FileTransfer |
setFileModificationTime(java.lang.String remoteFile,
java.util.Date dateFile)
Set file modifcation time.
|
FileTransfer |
setFileTimestamp(java.lang.String remoteFile,
java.util.Date timestamp)
Sets date/timestamp of remote file from server
When using the FTP/S protocols the MDTM command is used.
|
FileTransfer |
setHostname(java.lang.String host)
Sets hostname of server.
|
FileTransfer |
setLocalDir(java.io.File dir)
Sets local directory to be used in session.
|
FtpsTransfer |
setNATAddress(java.lang.String ipAddress)
Sets a NAT address which will be used after PASV command.
|
FileTransfer |
setPassive(boolean passive)
Sets whether passive mode is used for FTP connections.
|
FileTransfer |
setPassword(java.lang.String password)
Sets password.
|
FtpsTransfer |
setPerformMLSDListing(boolean mlsdListing)
Set MLSD directory listing.
|
FileTransfer |
setPort(int port)
Sets port of remote server.
|
FileTransfer |
setPreserveFileDownloadTimestamp(boolean value)
Set preserve file download timestamps.
|
FileTransfer |
setPreserveFileUploadTimestamp(boolean value)
Get preserve file upload timestamps.
|
FileTransfer |
setProxyAuthentication(java.lang.String proxyUsername,
java.lang.String proxyPassword)
Sets the proxy authentication username and password to use with
proxy server.
|
FileTransfer |
setProxyHost(java.lang.String proxyHostname,
int proxyPort)
Sets the proxy hostname and port for this connection.
|
FileTransfer |
setProxyType(java.lang.String proxyType)
Sets the proxy type will be used for this connection.
|
FtpsTransfer |
setServerCertificates(java.security.KeyStore keystore)
Sets optional server certificate keystore to use during authentication.
|
FtpsTransfer |
setServerCertificates(java.lang.String filename,
java.lang.String password)
Sets optional server certificate to be used during authentication.
|
FtpsTransfer |
setServerCertificates(java.lang.String filename,
java.lang.String password,
java.lang.String storetype)
Sets optional server certificate to be used during authentication.
|
FtpsTransfer |
setShutdownCCC(boolean value)
Sets whether SSL connection should be shutdown after successfully issuing
CCC command.
|
FtpsTransfer |
setTcpNoDelay(boolean value) |
FileTransfer |
setTimeout(long timeout)
Sets the timeout for opening connection to server.
|
FileTransfer |
setTimeZone(java.util.TimeZone timeZone)
Set the timezone, used for preserving timestamps.
|
FtpsTransfer |
setUseEPRT(boolean useEPRT)
Set use EPRT.
|
FtpsTransfer |
setUseEPSV(boolean useEPSV) |
FtpsTransfer |
setUseExtendedDirectoryListing(boolean useExtendedDirectoryListing)
Sets the use extended directory listing field.
|
FileTransfer |
setUsername(java.lang.String username)
Sets username.
|
FileTransfer |
setWireEncoding(java.lang.String encoding)
Sets encoding set used when issuing commands and transferring files.
|
void |
upload(byte[] data,
java.lang.String name)
Uploads file to server where contents of file is not on disk but
in memory.
|
void |
upload(byte[] data,
java.lang.String name,
boolean append)
Uploads file to server where contents of file is not on disk but
in memory.
|
void |
upload(java.io.File file)
Uploads file to server.
|
void |
upload(java.io.File file,
boolean append)
Uploads file to server.
|
void |
upload(java.io.File file,
java.lang.String remoteName)
Uploads file to server.
|
void |
upload(java.io.File file,
java.lang.String remoteName,
boolean append)
Uploads file to server.
|
void |
upload(java.io.InputStream in,
long length,
java.lang.String remoteFile,
boolean shouldAppend) |
void |
upload(java.lang.String name)
Uploads file to server.
|
void |
upload(java.lang.String name,
boolean append)
Uploads file to server.
|
void |
upload(java.lang.String extension,
java.io.File file)
Uploads file to server with the specified temporary extension.
|
void |
upload(java.lang.String name,
java.lang.String remoteName)
Uploads file to server.
|
void |
upload(java.lang.String name,
java.lang.String remoteName,
boolean append)
Uploads file to server.
|
void |
uploadDir(java.io.File localDir)
Uploads local directory and contents recursively to server.
|
void |
uploadDir(java.io.File localDir,
int retryLimit,
boolean performChecksum,
java.lang.String extension)
Uploads local directory and contents.
|
void |
uploadDir(java.io.File localDir,
int retryLimit,
boolean performChecksum,
java.lang.String extension,
int threadCount)
Uploads local directory and contents.
|
void |
uploadDir(java.io.File localDir,
java.lang.String extension)
Uploads local directory and contents recursively to 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.InputStream in,
java.lang.String remoteFilePrefix)
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.
|
public FtpsTransfer(java.lang.String host,
int port,
java.lang.String user,
java.lang.String password,
java.io.File localDirectory,
java.util.Set<FileTransferListener> listeners)
public FtpsTransfer(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 FtpsTransfer(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 FtpsTransfer(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
java.lang.Integer port)
host - user - pwd - port - public FtpsTransfer(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 userpublic FtpsTransfer()
public void addFtpsCertificateVerifier(FtpsCertificateVerifier listener)
listener - a FtpsCertificateVerifierFtpsCertificateVerifierpublic FtpsTransfer connect() throws FileTransferException
connect in interface FileTransferFileTransferException - if an I/O or server error occurs.FileTransfer.setUsername(java.lang.String),
FileTransfer.setPassword(java.lang.String)public void connect(boolean login)
throws FileTransferException
login - true to login, false otherwiseFileTransferExceptionpublic FileTransfer setPreserveFileUploadTimestamp(boolean value)
setPreserveFileUploadTimestamp in interface FileTransferpublic FileTransfer setPreserveFileDownloadTimestamp(boolean value)
setPreserveFileDownloadTimestamp in interface FileTransferpublic boolean isChecksumVerificationRequired()
isChecksumVerificationRequired in interface FileTransferpublic FileTransfer setChecksumVerificationRequired(boolean value)
setChecksumVerificationRequired in interface FileTransferpublic FileTransfer setTimeZone(java.util.TimeZone timeZone)
setTimeZone in interface FileTransferpublic void clearCommandChannel()
throws FileTransferException
FileTransferExceptionpublic FtpsTransfer setCompression(boolean compression)
compression - When it is true the data will be compressed before it is
sent between the client and the server.public void login()
throws FileTransferException
FileTransferException - if an I/O or FTP error occurspublic void issueCommand(java.lang.String command)
throws FileTransferException
command - a commandFileTransferException - if an error occurspublic void changePassword(java.lang.String oldPassword,
java.lang.String newPassword)
throws FileTransferException
oldPassword - The old password.newPassword - The new password.FileTransferException - FileTransferException if underlayed I/O or FTP error occurs.public void deleteDir(java.lang.String name)
throws FileTransferException
deleteDir in interface FileTransfername - the directory to removeFileTransferException - if an I/O or server error occurs.public void deleteDir(java.lang.String name,
boolean recursive)
throws FileTransferException
recursive
parameter will be used to determine if files and subdirectories within
directory should be removed.deleteDir in interface FileTransfername - the directory to removerecursive - true if it should delete files and subdirectories within directoryFileTransferException - if an I/O or server error occurs.public boolean exists(java.lang.String path)
throws FileTransferException
FileTransferexists in interface FileTransferpath - a path to verifytrue if path exists; false otherwiseFileTransferException - if an error occurspublic void deleteFile(java.lang.String remoteFile)
throws FileTransferException
deleteFile in interface FileTransferremoteFile - name of file to deleteFileTransferException - if an I/O or server error occurs.public void disconnect()
throws FileTransferException
disconnect in interface FileTransferFileTransferException - if an I/O or server error occurs.public void close()
close in interface FileTransferclose in interface java.lang.AutoCloseablepublic void download(java.io.OutputStream out,
java.lang.String remoteFile)
throws FileTransferException
OutputStream.
Closure of OutputStream is responsibility of programmer.download in interface FileTransferout - the OutputStream to write download toremoteFile - remote filenameFileTransferException - if an I/O or server error occurs.public java.io.File download(java.lang.String remoteFile)
throws FileTransferException
download in interface FileTransferremoteFile - the file to downloadFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File)public java.io.File download(java.lang.String localFile,
java.lang.String remoteFile)
throws FileTransferException
download in interface FileTransferlocalFile - destination filenameremoteFile - remote filenameFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File)public void downloadDir(java.lang.String remoteDir)
throws FileTransferException
downloadDir in interface FileTransferremoteDir - the directory to downloadFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File)public void downloadDir(java.lang.String remoteDir,
int retryLimit,
boolean performChecksum)
throws FileTransferException
downloadDir in interface FileTransferremoteDir - the directory to downloadretryLimit - retry limit if download failsperformChecksum - whether or not to perform checksum after download, only supported in FTP/S protocols and not by all FTP serversFileTransferException - if an I/O or protocol error occurs.public boolean getDebug()
getDebug in interface FileTransfertrue if debugging is onpublic java.io.PrintStream getDebugStream()
PrintStream is System.out.getDebugStream in interface FileTransferPrintStream used in reporting debug statementsPrintStreampublic java.lang.String getDir()
throws FileTransferException
getDir in interface FileTransferFileTransferException - if an I/O or server error occurs.public boolean getPerformMLSDListing()
public FtpsTransfer setPerformMLSDListing(boolean mlsdListing)
mlsdListing - - boolean valuepublic java.util.Enumeration<FileTransferRemoteFile> getDirListing() throws FileTransferException
getDirListing in interface FileTransferEnumeration of FileTransferRemoteFile objectsFileTransferException - if an I/O or server error occurs.FileTransfer.getDirListingAsString(String),
FileTransfer.getNameListing(java.lang.String)public java.util.Enumeration<FileTransferRemoteFile> getDirListing(java.lang.String filter) throws FileTransferException
getDirListing in interface FileTransferfilter - the filename filterEnumeration of FileTransferRemoteFile objectsFileTransferException - if an I/O or server error occurs.FileTransfer.getDirListingAsString(String),
FileTransfer.getNameListing(java.lang.String)public java.lang.String getDirListingAsString()
throws FileTransferException
getDirListingAsString in interface FileTransferFileTransferException - if an I/O or server error occurs.public java.lang.String getDirListingAsString(java.lang.String filter)
throws FileTransferException
getDirListingAsString in interface FileTransferfilter - a filename filterFileTransferException - if an I/O or server error occurs.public boolean isDirectory(java.lang.String remotePath)
throws FileTransferException
isDirectory in interface FileTransferFileTransferExceptionpublic long getFilesize(java.lang.String remoteFile)
throws FileTransferException
getFilesize in interface FileTransferremoteFile - the remote fileFileTransferException - if an I/O or protocol error occurs.public java.util.Date getFileTimestamp(java.lang.String remoteFile)
throws FileTransferException
getFileTimestamp in interface FileTransferremoteFile - the remote fileFileTransferException - if an I/O or server error occurs.public FileTransfer setFileTimestamp(java.lang.String remoteFile, java.util.Date timestamp) throws FileTransferException
setFileTimestamp in interface FileTransferremoteFile - the remote filetimestamp - the new date/timestampFileTransferException - if an I/O or server error occurs.public FileTransfer setFileModificationTime(java.lang.String remoteFile, java.util.Date dateFile) throws FileTransferException
setFileModificationTime in interface FileTransferremoteFile - - the remote file.dateFile - - the time.FileTransferExceptionpublic boolean sameChecksum(java.io.File localFile,
java.lang.String remoteFile)
throws FileTransferException
sameChecksum in interface FileTransferlocalFile - a local fileremoteFile - a remote filetrue if checksums are equal; false otherwiseFileTransferException - if an error occurspublic java.lang.String getHostname()
getHostname in interface FileTransferpublic java.io.File getLocalDir()
getLocalDir in interface FileTransferpublic java.util.Enumeration getLocalDirListing()
getLocalDirListing in interface FileTransferjava.util.Enumeration of Filepublic int getMode()
getMode in interface FileTransferFileTransfer.AUTO,
FileTransfer.BINARY,
FileTransfer.ASCIIpublic java.util.Enumeration getNameListing()
throws FileTransferException
getNameListing in interface FileTransferEnumeration of String where each item represents a file
or directory nameFileTransferException - if an I/O or server related error occurspublic java.util.Enumeration getNameListing(java.lang.String filter)
throws FileTransferException
getNameListing in interface FileTransferfilter - the filename filterEnumeration of String where each item represents a file
or directory nameFileTransferException - if an I/O or server related error occurspublic boolean getPassive()
getPassive in interface FileTransfertrue if passive mode is used, false otherwisepublic java.lang.String getPassword()
getPassword in interface FileTransferpublic int getPort()
getPort in interface FileTransferpublic long getTimeout()
getTimeout in interface FileTransferpublic java.lang.String getUsername()
getUsername in interface FileTransferpublic void interrupt()
interrupt in interface FileTransferFileTransfer.interrupt()public boolean interrupted()
interrupted in interface FileTransfertrue if transfer process was interrupted.public boolean isConnected()
isConnected in interface FileTransfertrue if connected false otherwisepublic void makeDir(java.lang.String name)
throws FileTransferException
makeDir in interface FileTransfername - name of directory to makeFileTransferException - if an I/O or server error occurs.public void makeDirRecursive(java.lang.String name)
throws FileTransferException
makeDirRecursive in interface FileTransfername - full path of directory to makeFileTransferException - if an I/O or server error occurspublic void mdelete(java.lang.String filter)
throws FileTransferException
mdelete in interface FileTransferfilter - the regular expression filter to useFileTransferException - if an error occurs.public java.io.File makeLocalDir(java.lang.String name)
makeLocalDir in interface FileTransfername - name of directoryFileTransfer.getLocalDir()public void mdownload(java.util.Enumeration fileNames)
throws FileTransferException
downloadDir(String) method.
Downloads are stored relative to current local directory.mdownload in interface FileTransferfileNames - filenames of files to downloadFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File),
FileTransfer.downloadDir(String)public void mdownload(java.lang.String filter)
throws FileTransferException
downloadDir method.mdownload in interface FileTransferfilter - the regular expression to useFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File),
FileTransfer.downloadDir(java.lang.String, int, boolean, int)public void mupload(java.util.Enumeration fileNames)
throws FileTransferException
mupload in interface FileTransferfileNames - filenames of files to uploadFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File)public void mupload(java.lang.String filter)
throws FileTransferException
mupload in interface FileTransferfilter - the regular expression to useFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File)public void renameFile(java.lang.String remoteFile,
java.lang.String newFile)
throws FileTransferException
renameFile in interface FileTransferremoteFile - name of file to renamenewFile - new name of fileFileTransferException - if an I/O or server error occurs.public void reset()
false.
This method should be invoked if you have interrupted a transfer using the
interrupt method and wish to resume transfering files.reset in interface FileTransferFileTransfer.interrupt()public void resumeDownload(java.lang.String remoteFile,
long offset)
throws FileTransferException
resumeDownload in interface FileTransferremoteFile - the file to downloadoffset - file offset in bytesFileTransferException - if an I/O or server error occurs.public void resumeDownload(java.lang.String localFile,
java.lang.String remoteFile,
long offset)
throws FileTransferException
resumeDownload in interface FileTransferlocalFile - local file nameremoteFile - the file to downloadoffset - file offset in bytesFileTransferException - if an I/O or server error occurs.public void resumeUpload(java.io.File file,
long offset)
throws FileTransferException
resumeUpload in interface FileTransferfile - the local file to uploadoffset - file offset in bytesFileTransferException - if an I/O or server error occurs.public void resumeUpload(java.lang.String file,
long offset)
throws FileTransferException
resumeUpload in interface FileTransferfile - the local file to uploadoffset - file offset in bytesFileTransferException - if an I/O or server error occurs.public FileTransfer setAscii()
setAscii in interface FileTransferpublic FileTransfer setAuto(boolean auto)
setAuto in interface FileTransferauto - true to turn automatic detect on false to turn offpublic FileTransfer setBinary()
setBinary in interface FileTransferpublic FileTransfer setDebug(boolean debug)
System.out.setDebug in interface FileTransferdebug - true to turn debugging onFileTransfer.setDebugStream(java.io.PrintStream)public FileTransfer setDebugStream(java.io.PrintStream ps)
PrintStream used in reporting debug statements.
Default debug stream is System.out.setDebugStream in interface FileTransferps - the PrintStream to send debug statements toPrintStreampublic FileTransfer setDir(java.lang.String name) throws FileTransferException
setDir in interface FileTransfername - the remote directoryFileTransferException - if an I/O or server error occurs.public FileTransfer setDirUp() throws FileTransferException
setDirUp in interface FileTransferFileTransferException - if an I/O or server error occurs.public FtpsTransfer setErrorOnSizeCommand(boolean error)
error - Error indicator valuepublic boolean getErrorOnSizeCommand()
true then method which invokes getFileSize will throw
an exception when it caused an error, false the error will be ignored.public FileTransfer setHostname(java.lang.String host)
setHostname in interface FileTransferhost - the hostname or IP address of serverpublic FileTransfer setPort(int port)
setPort in interface FileTransferport - the portpublic FileTransfer setLocalDir(java.io.File dir)
setLocalDir in interface FileTransferdir - the local directorypublic boolean getTcpNoDelay()
public FtpsTransfer setTcpNoDelay(boolean value)
public FtpsTransfer setNATAddress(java.lang.String ipAddress) throws FileTransferException
ipAddress - The NAT IP address.FtpException - If an error occurs.FileTransferExceptionpublic FileTransfer setPassive(boolean passive)
setPassive in interface FileTransferpassive - if true, the transfers will be passive.public FileTransfer setPassword(java.lang.String password)
setPassword in interface FileTransferpassword - the passwordpublic FtpsTransfer setClientCertificates(java.security.KeyStore keystore, java.lang.String password) throws FileTransferException
keystore - the client keystorepassword - the keystore passwordFileTransferException - if an I/O error occurspublic FtpsTransfer setClientCertificates(java.lang.String filename, java.lang.String password) throws FileTransferException
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 passwordFileTransferException - if an I/O error occurspublic FtpsTransfer setClientCertificates(java.lang.String filename, java.lang.String password, java.lang.String storetype) throws FileTransferException
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 pkcs12FileTransferException - if an I/O error occurspublic FtpsTransfer setServerCertificates(java.security.KeyStore keystore) throws FileTransferException
keystore - the keystoreFileTransferException - if an I/O error occurspublic FtpsTransfer setServerCertificates(java.lang.String filename, java.lang.String password) throws FileTransferException
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 passwordFileTransferException - if an I/O error occurspublic FtpsTransfer setServerCertificates(java.lang.String filename, java.lang.String password, java.lang.String storetype) throws FileTransferException
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 pkcs12FileTransferException - if an I/O error occurspublic FileTransfer setTimeout(long timeout)
setTimeout in interface FileTransfertimeout - the timeout in millisecondspublic FileTransfer setUsername(java.lang.String username)
setUsername in interface FileTransferusername - the usernamepublic FtpsTransfer setUseEPSV(boolean useEPSV)
public FtpsTransfer setUseEPRT(boolean useEPRT)
useEPRT - public FtpsTransfer setAutoDetectIpv6(boolean value)
value - public FtpsTransfer setUseExtendedDirectoryListing(boolean useExtendedDirectoryListing)
useExtendedDirectoryListing - The use extended directory listing indicator.public boolean getUseEPSV()
true the passive mode will be sent EPSV commandpublic boolean getUseEPRT()
true active mode will be sent EPRT commandpublic boolean getAutoDetectIpv6()
true if auto-detect Ipv6 is set to truepublic FtpsTransfer setConnectBeforeCommand(boolean before)
before - indicates if the connection will be established before send
the command in passive modepublic FileTransfer setWireEncoding(java.lang.String encoding)
setWireEncoding in interface FileTransferencoding - the character encoding to be usedpublic java.lang.String getWireEncoding()
getWireEncoding in interface FileTransferpublic java.lang.String getRemoteFileChecksum(java.lang.String remoteFile)
throws FtpException
remoteFile - remote fileFtpException - if an error occurspublic java.lang.String getLocalChecksum(java.io.File localFile)
throws FtpException
localFile - File which will be calculate the checksumFtpException - if an error occurspublic void upload(byte[] data,
java.lang.String name)
throws FileTransferException
upload in interface FileTransferdata - the raw contents of the file to uploadname - the filename to store file as on FTP serverFileTransferException - if an I/O or server related error occurspublic void upload(byte[] data,
java.lang.String name,
boolean append)
throws FileTransferException
upload in interface FileTransferdata - the raw contents of the file to uploadname - the filename to store file as on serverappend - true to append to remote file on FTP server, false otherwiseFileTransferException - if an I/O or server related error occurspublic void upload(java.io.File file)
throws FileTransferException
file is a directory then directory and entire contents are uploaded.upload in interface FileTransferfile - the local file to uploadFileTransferException - if an I/O or server related error occurspublic void upload(java.io.File file,
boolean append)
throws FileTransferException
file is a directory then directory and entire contents are uploaded.upload in interface FileTransferfile - the local file to uploadappend - true to append to remote file on server, false otherwiseFileTransferException - if an I/O or server related error occurspublic void upload(java.lang.String extension,
java.io.File file)
throws FileTransferException
upload in interface FileTransferextension - the temporary extension to use when uploading the filefile - the file to be uploadedFileTransferException - if an I/O or protocol error occurspublic void upload(java.io.File file,
java.lang.String remoteName)
throws FileTransferException
file is a directory then directory and entire contents are uploaded.upload in interface FileTransferfile - the local file to uploadremoteName - the destination filename of uploadFileTransferException - if an I/O or server related error occurspublic void upload(java.io.File file,
java.lang.String remoteName,
boolean append)
throws FileTransferException
file is a directory then directory and entire contents are uploaded.upload in interface FileTransferfile - the local file to uploadremoteName - the destination filename of uploadappend - true to append to remote file on server, false otherwiseFileTransferException - if an I/O or server related error occurspublic void upload(java.lang.String name)
throws FileTransferException
upload in interface FileTransfername - the local file to uploadFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File)public void upload(java.lang.String name,
boolean append)
throws FileTransferException
upload in interface FileTransfername - the local file to uploadappend - true to append to remote file on server, false otherwiseFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File)public void upload(java.lang.String name,
java.lang.String remoteName)
throws FileTransferException
upload in interface FileTransfername - the local file to uploadremoteName - the destination of uploadFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File)public void upload(java.lang.String name,
java.lang.String remoteName,
boolean append)
throws FileTransferException
upload in interface FileTransfername - the local file to uploadremoteName - the destination of uploadappend - true to append to remote file on FTP server, false otherwiseFileTransferException - if an I/O or server error occurs.FileTransfer.setLocalDir(java.io.File)public java.lang.String uploadUnique(java.lang.String fileName)
throws FileTransferException
uploadUnique in interface FileTransferfileName - the file to be uploaded relative to current local directoryFileTransferException - if an I/O or protocol error occurs.FileTransfer.setLocalDir(File)public java.lang.String uploadUnique(java.io.File file)
throws FileTransferException
uploadUnique in interface FileTransferfile - the file to be uploadedFileTransferException - if an I/O or protocol error occurs.public java.lang.String uploadUnique(java.io.InputStream in,
java.lang.String remoteFilePrefix)
throws FileTransferException
uploadUnique in interface FileTransferin - the InputStream to upload file fromremoteFilePrefix - the filename to be used as seed value for determining unique filenameFileTransferException - if an I/O or protocol error occurs.public void uploadDir(java.io.File localDir)
throws FileTransferException
uploadDir in interface FileTransferlocalDir - the directory to uploadFileTransferException - if an I/O or protocol error occurs.public void uploadDir(java.io.File localDir,
java.lang.String extension)
throws FileTransferException
uploadDir in interface FileTransferlocalDir - the directory to uploadextension - The extension file name used to upload each fileFileTransferException - if an I/O or protocol error occurs.public void uploadDir(java.io.File localDir,
int retryLimit,
boolean performChecksum,
java.lang.String extension)
throws FileTransferException
uploadDir in interface FileTransferlocalDir - the directory to uploadretryLimit - retry number when an error occursperformChecksum - whether or not to perform checksum verificationextension - the temporary extension which will be used when uploading files or null to use current extensionFileTransferException - if an I/O or protocol related error occurs.public void addFileTransferListener(FileTransferListener listener)
addFileTransferListener in interface FileTransferlistener - the listener to addFileTransferListenerpublic void removeFileTransferListener(FileTransferListener listener)
removeFileTransferListener in interface FileTransferlistener - the listener to removeFileTransferListenerpublic java.io.InputStream getInputStream(java.lang.String remoteFile,
long pos)
throws FileTransferException
InputStream for remote file for reading.getInputStream in interface FileTransferremoteFile - the remote file to get InputStream forpos - the byte offset, 0 to get full fileInputStreamFileTransferException - if an I/O or protocol related error occurspublic java.lang.Object getImplementation()
getImplementation in interface FileTransferFtp, Ftps or SftpFtp,
Ftpspublic java.io.OutputStream getOutputStream(java.lang.String fileName,
long off)
throws FileTransferException
OutputStream for writing to remote file.getOutputStream in interface FileTransferfileName - the remote filenameoff - the byte offset, 0 to write at beginning of fileOutputStreamFileTransferException - if an I/O or protocol related error occurspublic FileTransfer copy()
copy in interface FileTransferpublic FileTransfer setBlockTransferSize(int blocksize)
setBlockTransferSize in interface FileTransferblocksize - the blocksize in bytespublic int getBlockTransferSize()
getBlockTransferSize in interface FileTransferpublic FtpsTransfer setShutdownCCC(boolean value)
value - true to shutdown, false
otherwisepublic boolean getShutdownCCC()
true to shutdown, false otherwisepublic FileTransfer setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)
setProxyAuthentication in interface FileTransferproxyUsername - the proxy usernameproxyPassword - the proxy passwordFileTransfer.clearProxySettings()public FileTransfer setProxyHost(java.lang.String proxyHostname, int proxyPort)
setProxyHost in interface FileTransferproxyHostname - the hostname or ip address of the proxy serverproxyPort - the port of the proxy server to connect toFileTransfer.clearProxySettings()public FileTransfer setProxyType(java.lang.String proxyType)
setProxyType in interface FileTransferproxyType - The proxy type. Values allowed: HTTP, SOCKS5public void clearProxySettings()
clearProxySettings in interface FileTransferpublic boolean isFeatureSupported(java.lang.String command)
throws FileTransferException
FileTransferExceptionpublic void checksum(java.io.File localFile,
java.lang.String remoteFile)
throws FileTransferException
FileTransferExceptionpublic void abortDownloadThread(java.lang.String remoteFile)
abortDownloadThread in interface FileTransferpublic void abortDownloadThreads()
abortDownloadThreads in interface FileTransferpublic void abortUploadThread(java.lang.String remoteFile)
abortUploadThread in interface FileTransferpublic void abortUploadThreads()
abortUploadThreads in interface FileTransferpublic void downloadDir(java.lang.String remoteDir,
int retryLimit,
boolean performChecksum,
int threadCount)
throws FileTransferException
downloadDir in interface FileTransferremoteDir - the directory to downloadretryLimit - retry limit if download failsperformChecksum - whether or not to perform checksum after download, only supported in FTP/S protocols and not by all FTP serversthreadCount - the thread countFileTransferException - if an I/O or protocol error occurs.public java.util.Vector<FileTransferRemoteFile> getRemoteFileList(java.lang.String remoteDirectory) throws FileTransferException
getRemoteFileList in interface FileTransferFileTransferExceptionpublic int getRecursiveDirectoryFileCount(java.lang.String directory)
getRecursiveDirectoryFileCount in interface FileTransferpublic long getRecursiveDirectorySize(java.lang.String directory)
getRecursiveDirectorySize in interface FileTransferpublic void uploadDir(java.io.File localDir,
int retryLimit,
boolean performChecksum,
java.lang.String extension,
int threadCount)
throws FileTransferException
uploadDir in interface FileTransferlocalDir - the directory to uploadretryLimit - retry number when an error occursperformChecksum - whether or not to perform checksum verificationextension - the temporary extension which will be used when uploading files or null to use current extensionFileTransferException - if an I/O or protocol related error occurs.public void resumeUpload(java.io.File localFile,
java.lang.String remoteFile,
long localFileOffset)
throws FileTransferException
resumeUpload in interface FileTransferFileTransferExceptionpublic void resumeDownload(java.io.OutputStream out,
java.lang.String remoteFile,
long remoteFileOffset)
throws FileTransferException
resumeDownload in interface FileTransferFileTransferExceptionpublic void upload(java.io.InputStream in,
long length,
java.lang.String remoteFile,
boolean shouldAppend)
throws FileTransferException
upload in interface FileTransferFileTransferExceptionpublic void resumeUpload(java.io.InputStream in,
long length,
java.lang.String remoteFile,
long remoteFileOffset)
throws FileTransferException
resumeUpload in interface FileTransferFileTransferExceptionCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved