Secure iNet Factory

com.jscape.filetransfer
Interface FileTransfer

All Known Implementing Classes:
FtpsImplicitTransfer, FtpsTransfer, FtpTransfer, SftpTransfer

public interface FileTransfer

Abstract interface for performing file transfer operations using FTP, FTPS (FTP over SSL) and SFTP (FTP over SSH) protocols.

Example Usage:

 FileTransfer ftp = new FtpFileTransfer(hostname,username,password);
 ftp.connect();
 System.out.println(ftp.getDirListingAsString());
 ftp.disconnect();
 

See Also:
FtpTransfer, FtpsTransfer, SftpTransfer, FtpsImplicitTransfer

Field Summary
static int ASCII
          Flag to indicate that ASCII transfer mode is used.
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 java.lang.String UP_DIR
          Represents the parent directory of current directory.
 
Method Summary
 void abortDownloadThread(java.lang.String file)
          Abort download thread.
 void abortDownloadThreads()
          Abort all download threads.
 void abortUploadThread(java.lang.String file)
          Abort upload thread.
 void abortUploadThreads()
          Abort all upload threads.
 void addFileTransferListener(FileTransferListener listener)
          Adds FileTransferListener.
 void clearProxySettings()
          Clears proxy server values.
 void connect()
          Connects to server and performs 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.
 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 getDirListing()
          Gets directory listing from server.
 java.util.Enumeration 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.
 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.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, boolean append)
          Gets OutputStream for writing to remote file.
 boolean getPassive()
          Gets whether passive mode is used for FTP connections.
 java.lang.String getPassword()
          Gets password.
 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.util.Vector getRemoteFileList(java.lang.String directory)
          Get remote directory list.
 long getTimeout()
          Gets the timeout for opening connection to server.
 java.lang.String getUsername()
          Gets username.
 java.lang.String getWireEncoding()
          Gets encoding set used when issuing commands and transferring files.
 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 server.
 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.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 off)
          Resume upload of file to server.
 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.
 void setAscii()
          Sets data transfer mode to ASCII.
 void setAuto(boolean auto)
          Sets data transfer mode to automatically detect transfer mode.
 void setBinary()
          Sets data transfer mode to binary.
 void setBlockTransferSize(int blocksize)
          Sets block size for use in transferring files.
 void setDebug(boolean debug)
          Sets debugging state.
 void setDebugStream(java.io.PrintStream ps)
          Sets PrintStream used in reporting debug statements.
 void setDir(java.lang.String name)
          Sets current directory on server.
 void setDirUp()
          Sets current directory on server to parent directory.
 void setFileModificationTime(java.lang.String remoteFile, java.util.Date dateFile)
          Set file modifcation time.
 void setFileTimestamp(java.lang.String remoteFile, java.util.Date dateFile)
          Sets date/timestamp of remote file from server

When using the FTP/S protocols the MDTM command is used.

 void setHostname(java.lang.String host)
          Sets hostname of server.
 void setLocalDir(java.io.File dir)
          Sets local directory to be used in session.
 void setPassive(boolean passive)
          Sets whether passive mode is used for FTP connections.
 void setPassword(java.lang.String password)
          Sets password.
 void setPort(int port)
          Sets port of remote server.
 void setPreserveFileDownloadTimestamp(boolean value)
          Set preserve file download timestamps.
 void setPreserveFileUploadTimestamp(boolean value)
          Get preserve file upload timestamps.
 void setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)
          Sets the proxy authentication username and password to use with proxy server.
 void setProxyHost(java.lang.String proxyHostname, int proxyPort)
          Sets the proxy hostname and port for this connection.
 void setProxyType(java.lang.String proxyType)
          Sets the proxy type will be used for this connection.
 void setTimeout(long timeout)
          Sets the timeout for opening connection to server.
 void setTimeZone(java.util.TimeZone timeZone)
          Set the timezone, used for preserving timestamps.
 void setUsername(java.lang.String username)
          Sets username.
 void 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.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 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.
 

Field Detail

AUTO

static final int AUTO
Flag to indicate that automatic transfer mode detection is used.

See Also:
getMode(), Constant Field Values

ASCII

static final int ASCII
Flag to indicate that ASCII transfer mode is used.

See Also:
getMode(), Constant Field Values

BINARY

static final int BINARY
Flag to indicate that BINARY transfer mode is used.

See Also:
getMode(), Constant Field Values

CURRENT_DIR

static final java.lang.String CURRENT_DIR
Represents the current directory. Value of "."

See Also:
Constant Field Values

UP_DIR

static final java.lang.String UP_DIR
Represents the parent directory of current directory. Value of ".."

See Also:
Constant Field Values
Method Detail

getHostname

java.lang.String getHostname()
Gets hostname of server.

Returns:
hostname

setHostname

void setHostname(java.lang.String host)
Sets hostname of server.

Parameters:
host - the hostname or IP address of server

getPort

int getPort()
Gets server port. Default value is 21.

Returns:
server port

setPort

void setPort(int port)
Sets port of remote server.

Parameters:
port - the port

getTimeout

long getTimeout()
Gets the timeout for opening connection to server.

Returns:
timeout in milliseconds

setTimeout

void setTimeout(long timeout)
Sets the timeout for opening connection to server.

Parameters:
timeout - the timeout in milliseconds

getUsername

java.lang.String getUsername()
Gets username.

Returns:
username

setUsername

void setUsername(java.lang.String username)
Sets username.

Parameters:
username - the username

getPassword

java.lang.String getPassword()
Gets password.

Returns:
the password

setPassword

void setPassword(java.lang.String password)
Sets password.

Parameters:
password - the password

getBlockTransferSize

int getBlockTransferSize()
Gets blocksize for use in transferring files.

Returns:
blocksize in bytes

setBlockTransferSize

void setBlockTransferSize(int blocksize)
Sets block size for use in transferring files.

Parameters:
blocksize - the blocksize in bytes

getPassive

boolean getPassive()
Gets whether passive mode is used for FTP connections.

Returns:
true if passive mode is used, false otherwise

setPassive

void setPassive(boolean passive)
Sets whether passive mode is used for FTP connections.

Parameters:
passive - if true, the transfers will be passive.

getWireEncoding

java.lang.String getWireEncoding()
Gets encoding set used when issuing commands and transferring files.

Returns:
Returns the encoding is being used

setWireEncoding

void setWireEncoding(java.lang.String encoding)
Sets encoding set used when issuing commands and transferring files. The default encoding is UTF8

Parameters:
encoding - the character encoding to be used

setPreserveFileUploadTimestamp

void setPreserveFileUploadTimestamp(boolean value)
Get preserve file upload timestamps.

Parameters:
value -

setPreserveFileDownloadTimestamp

void setPreserveFileDownloadTimestamp(boolean value)
Set preserve file download timestamps.

Parameters:
value -

setTimeZone

void setTimeZone(java.util.TimeZone timeZone)
Set the timezone, used for preserving timestamps.

Parameters:
timeZone -

setProxyHost

void setProxyHost(java.lang.String proxyHostname,
                  int proxyPort)
Sets the proxy hostname and port for this connection. To clear these settings invoke the #clearProxySettings method.

Parameters:
proxyHostname - the hostname or ip address of the proxy server
proxyPort - the port of the proxy server to connect to
See Also:
clearProxySettings()

setProxyAuthentication

void setProxyAuthentication(java.lang.String proxyUsername,
                            java.lang.String proxyPassword)
Sets the proxy authentication username and password to use with proxy server. To clear these settings invoke the #clearProxySettings method.

Parameters:
proxyUsername - the proxy username
proxyPassword - the proxy password
See Also:
clearProxySettings()

setProxyType

void setProxyType(java.lang.String proxyType)
Sets the proxy type will be used for this connection.

Parameters:
proxyType - The proxy type. Values allowed: HTTP, SOCKS5

clearProxySettings

void clearProxySettings()
Clears proxy server values.


getDebug

boolean getDebug()
Gets debugging state.

Returns:
true if debugging is on

setDebug

void setDebug(boolean debug)
Sets debugging state. All debug statements are reported to debug stream. Default debug stream is System.out.

Parameters:
debug - true to turn debugging on
See Also:
setDebugStream(java.io.PrintStream)

getDebugStream

java.io.PrintStream getDebugStream()
Gets PrintStream used in reporting debug statements. Default PrintStream is System.out.

Returns:
the PrintStream used in reporting debug statements
See Also:
PrintStream

setDebugStream

void setDebugStream(java.io.PrintStream ps)
Sets PrintStream used in reporting debug statements. Default debug stream is System.out.

Parameters:
ps - the PrintStream to send debug statements to
See Also:
PrintStream

addFileTransferListener

void addFileTransferListener(FileTransferListener listener)
Adds FileTransferListener.

Parameters:
listener - the listener to add
See Also:
FileTransferListener

removeFileTransferListener

void removeFileTransferListener(FileTransferListener listener)
Removes specified FileTransferListener.

Parameters:
listener - the listener to remove
See Also:
FileTransferListener

getLocalDir

java.io.File getLocalDir()
Gets local directory to be used in session. Downloads will be stored relative to local directory. Uploads are performed relative to current local directory.

Returns:
the local directory

setLocalDir

void setLocalDir(java.io.File dir)
Sets local directory to be used in session. Downloads will be stored relative to local directory. Uploads are performed relative to current local directory.

Parameters:
dir - the local directory

getLocalDirListing

java.util.Enumeration getLocalDirListing()
Gets local directory listing.

Returns:
an java.util.Enumeration of File

makeLocalDir

java.io.File makeLocalDir(java.lang.String name)
Creates local directory. Directory is relative to current local directory

Parameters:
name - name of directory
Returns:
the directory
See Also:
getLocalDir()

getImplementation

java.lang.Object getImplementation()
Gets underlying file transfer instance.

Returns:
an instance of Ftp, Ftps or Sftp
See Also:
Ftp, Ftps

copy

FileTransfer copy()
Returns a copy of current transfer instance with same listeners.

Returns:
a copy of current transfer instance

connect

void connect()
             throws FileTransferException
Connects to server and performs login.

Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setUsername(java.lang.String), setPassword(java.lang.String)

disconnect

void disconnect()
                throws FileTransferException
Quits session and disconnects from server.

Throws:
FileTransferException - if an I/O or server error occurs.

isConnected

boolean isConnected()
Checks if client is connected to server.

Returns:
true if connected false otherwise

getMode

int getMode()
Gets data transfer mode for current session. Default mode is FileTransfer.AUTO where 0 = AUTO, 1 = ASCII, 2 = BINARY

Returns:
the data transfer mode
See Also:
AUTO, BINARY, ASCII

setAscii

void setAscii()
              throws FileTransferException
Sets data transfer mode to ASCII. You must be connected to the server prior to invoking this method.

Throws:
FileTransferException - if an I/O or server error occurs.

setAuto

void setAuto(boolean auto)
             throws FileTransferException
Sets data transfer mode to automatically detect transfer mode. Any files with a base Content-Type value of text will be transferred using ASCII, all other files will be transfered using binary.

Example: file.txt, Content-Type = text/plain, uploaded using ASCII
Example: image.jpg Content-Type = image/jpg, uploaded using binary

Parameters:
auto - true to turn automatic detect on false to turn off
Throws:
FileTransferException - if an I/O or server error occurs.

setBinary

void setBinary()
               throws FileTransferException
Sets data transfer mode to binary. You must be connected to the server prior to invoking this method.

Throws:
FileTransferException - if an I/O or server error occurs.

getDir

java.lang.String getDir()
                        throws FileTransferException
Gets current working directory of server.

Returns:
current directory
Throws:
FileTransferException - if an I/O or server error occurs.

setDir

void setDir(java.lang.String name)
            throws FileTransferException
Sets current directory on server.

Parameters:
name - the remote directory
Throws:
FileTransferException - if an I/O or server error occurs.

setDirUp

void setDirUp()
              throws FileTransferException
Sets current directory on server to parent directory.

Throws:
FileTransferException - if an I/O or server error occurs.

getDirListing

java.util.Enumeration getDirListing()
                                    throws FileTransferException
Gets directory listing from server.

Returns:
an Enumeration of FileTransferRemoteFile objects
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
getDirListingAsString(String), getNameListing()

getDirListing

java.util.Enumeration getDirListing(java.lang.String filter)
                                    throws FileTransferException
Gets file listing of files matching regular expression. For example the regular expression ".*\\.txt" may return all files containing a .txt filename extension.

Parameters:
filter - the filename filter
Returns:
an Enumeration of FileTransferRemoteFile objects
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
getDirListingAsString(String), getNameListing()

getDirListingAsString

java.lang.String getDirListingAsString()
                                       throws FileTransferException
Gets directory listing of files on server.

Returns:
a directory listing
Throws:
FileTransferException - if an I/O or server error occurs.

getDirListingAsString

java.lang.String getDirListingAsString(java.lang.String filter)
                                       throws FileTransferException
Gets file listing of files matching regular expression. For example the regular expression ".*\\.txt" may return all files containing a .txt filename extension.

Parameters:
filter - a filename filter
Returns:
a directory listing
Throws:
FileTransferException - if an I/O or server error occurs.

getNameListing

java.util.Enumeration getNameListing()
                                     throws FileTransferException
Gets directory listing of files on server.

Returns:
an Enumeration of String where each item represents a file or directory name
Throws:
FileTransferException - if an I/O or server related error occurs

getNameListing

java.util.Enumeration getNameListing(java.lang.String filter)
                                     throws FileTransferException
Gets directory listing of files on server matching regular expression. For example ".*\\.txt" may return all files containing a .txt filename extension.

Parameters:
filter - the filename filter
Returns:
an Enumeration of String where each item represents a file or directory name
Throws:
FileTransferException - if an I/O or server related error occurs

getRecursiveDirectorySize

long getRecursiveDirectorySize(java.lang.String directory)
                               throws FileTransferException
Get recursive directory size.

Parameters:
directory -
Returns:
Throws:
FileTransferException

getRecursiveDirectoryFileCount

int getRecursiveDirectoryFileCount(java.lang.String directory)
                                   throws FileTransferException
Get recursive directory file count.

Parameters:
directory -
Returns:
Throws:
FileTransferException

getRemoteFileList

java.util.Vector getRemoteFileList(java.lang.String directory)
                                   throws FileTransferException
Get remote directory list.

Parameters:
directory -
Returns:
Throws:
FileTransferException

makeDir

void makeDir(java.lang.String name)
             throws FileTransferException
Makes directory on server.

Parameters:
name - name of directory to make
Throws:
FileTransferException - if an I/O or server error occurs.

makeDirRecursive

void makeDirRecursive(java.lang.String name)
                      throws FileTransferException
Makes directory on server, creating subdirectories if necessary.

Parameters:
name - full path of directory to make
Throws:
FileTransferException - if an I/O or server error occurs

deleteDir

void deleteDir(java.lang.String name)
               throws FileTransferException
Deletes directory from server.

Parameters:
name - the directory to remove
Throws:
FileTransferException - if an I/O or server error occurs.

deleteDir

void deleteDir(java.lang.String name,
               boolean recursive)
               throws FileTransferException
Deletes directory from server. If the directory cannot be deleted because it is not empty the recursive parameter will be used to determine if files and subdirectories within directory should be removed.

Parameters:
name - the directory to remove
recursive - true if it should delete files and subdirectories within directory
Throws:
FileTransferException - if an I/O or server error occurs.

getFilesize

long getFilesize(java.lang.String remoteFile)
                 throws FileTransferException
Gets filesize of remote file from server.

When using the FTP/S protocols the SIZE command is used. The SIZE command is not part of RFC-959 so may not work on all FTP servers.

Parameters:
remoteFile - the remote file
Returns:
filesize in bytes
Throws:
FileTransferException - if an I/O or protocol error occurs.

getFileTimestamp

java.util.Date getFileTimestamp(java.lang.String remoteFile)
                                throws FileTransferException
Gets date/timestamp of remote file from server.

When using the FTP/S protocols the MDTM command is used. The MDTM command is not part of RFC-959 so may not work on all FTP servers.

Parameters:
remoteFile - the remote file
Returns:
date the date/timestamp of remote file
Throws:
FileTransferException - if an I/O or server error occurs.

setFileTimestamp

void setFileTimestamp(java.lang.String remoteFile,
                      java.util.Date dateFile)
                      throws FileTransferException
Sets date/timestamp of remote file from server

When using the FTP/S protocols the MDTM command is used. The MDTM command is not part of RFC-959 so may not work on all FTP servers.

Parameters:
remoteFile - the remote file
dateFile - the new date/timestamp
Throws:
FileTransferException - if an I/O or server error occurs.

setFileModificationTime

void setFileModificationTime(java.lang.String remoteFile,
                             java.util.Date dateFile)
                             throws FileTransferException
Set file modifcation time.

Parameters:
remoteFile - - the remote file.
dateFile - - the time.
Throws:
FileTransferException

sameChecksum

boolean sameChecksum(java.io.File localFile,
                     java.lang.String remoteFile)
                     throws FileTransferException
Checks a checksum equality of local and remote files.

Parameters:
localFile - a local file
remoteFile - a remote file
Returns:
true if checksums are equal; false otherwise
Throws:
FileTransferException - if an error occurs

renameFile

void renameFile(java.lang.String remoteFile,
                java.lang.String newFile)
                throws FileTransferException
Renames remote file on server.

Parameters:
remoteFile - name of file to rename
newFile - new name of file
Throws:
FileTransferException - if an I/O or server error occurs.

deleteFile

void deleteFile(java.lang.String remoteFile)
                throws FileTransferException
Deletes remote file from server.

Parameters:
remoteFile - name of file to delete
Throws:
FileTransferException - if an I/O or server error occurs.

mdelete

void mdelete(java.lang.String filter)
             throws FileTransferException
Deletes multiple files in servers current directory matching regular expression. For example, to delete all files ending with .txt extension you may use the regular expression ".*\\.txt".

Parameters:
filter - the regular expression filter to use
Throws:
FileTransferException - if an error occurs.

download

void download(java.io.OutputStream out,
              java.lang.String remoteFile)
              throws FileTransferException
Downloads file from server and writes contents to provided OutputStream. Closure of OutputStream is responsibility of programmer.

Parameters:
out - the OutputStream to write download to
remoteFile - remote filename
Throws:
FileTransferException - if an I/O or server error occurs.

download

java.io.File download(java.lang.String remoteFile)
                      throws FileTransferException
Downloads file from server. Downloads are stored relative to current local directory.

Parameters:
remoteFile - the file to download
Returns:
File the file downloaded
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

download

java.io.File download(java.lang.String localFile,
                      java.lang.String remoteFile)
                      throws FileTransferException
Downloads file from server. Downloads are stored relative to current local directory.

Parameters:
localFile - destination filename
remoteFile - remote filename
Returns:
File the file downloaded
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

resumeDownload

void resumeDownload(java.lang.String remoteFile,
                    long offset)
                    throws FileTransferException
Resumes download of file from server.

Parameters:
remoteFile - the file to download
offset - file offset in bytes
Throws:
FileTransferException - if an I/O or server error occurs.

resumeDownload

void resumeDownload(java.lang.String localFile,
                    java.lang.String remoteFile,
                    long offset)
                    throws FileTransferException
Resumes download of file from server.

Parameters:
localFile - local file name
remoteFile - the file to download
offset - file offset in bytes
Throws:
FileTransferException - if an I/O or server error occurs.

mdownload

void mdownload(java.util.Enumeration fileNames)
               throws FileTransferException
Downloads specified files in current working remote directory from server to local directory. Do not use this method to download a directory, see downloadDir(String) method.

Downloads are stored relative to current local directory.

Parameters:
fileNames - filenames of files to download
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File), downloadDir(String)

mdownload

void mdownload(java.lang.String filter)
               throws FileTransferException
Downloads multiple files matching regular expression from server's current directory. Downloads are stored relative to current local directory. For example, to download all files ending with extension .txt use the filter ".*\\.txt".

To download a directory use the downloadDir method.

Parameters:
filter - the regular expression to use
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File), downloadDir(java.lang.String)

downloadDir

void downloadDir(java.lang.String remoteDir)
                 throws FileTransferException
Downloads remote directory and contents recursively from server. Downloads are stored relative to current local directory.

Parameters:
remoteDir - the directory to download
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

downloadDir

void downloadDir(java.lang.String remoteDir,
                 int retryLimit,
                 boolean performChecksum)
                 throws FileTransferException
Downloads remote directory and contents. Downloads are stored relative to current local directory.

Parameters:
remoteDir - the directory to download
retryLimit - retry limit if download fails
performChecksum - whether or not to perform checksum after download, only supported in FTP/S protocols and not by all FTP servers
Throws:
FileTransferException - if an I/O or protocol error occurs.

downloadDir

void downloadDir(java.lang.String remoteDir,
                 int retryLimit,
                 boolean performChecksum,
                 int threadCount)
                 throws FileTransferException
Downloads remote directory and contents. Downloads are stored relative to current local directory.

Parameters:
remoteDir - the directory to download
retryLimit - retry limit if download fails
performChecksum - whether or not to perform checksum after download, only supported in FTP/S protocols and not by all FTP servers
threadCount - the thread count
Throws:
FileTransferException - if an I/O or protocol error occurs.

upload

void upload(byte[] data,
            java.lang.String name)
            throws FileTransferException
Uploads file to server where contents of file is not on disk but in memory.

Parameters:
data - the raw contents of the file to upload
name - the filename to store file as on FTP server
Throws:
FileTransferException - if an I/O or server related error occurs

upload

void upload(byte[] data,
            java.lang.String name,
            boolean append)
            throws FileTransferException
Uploads file to server where contents of file is not on disk but in memory.

Parameters:
data - the raw contents of the file to upload
name - the filename to store file as on server
append - true to append to remote file on FTP server, false otherwise
Throws:
FileTransferException - if an I/O or server related error occurs

upload

void upload(java.io.File file)
            throws FileTransferException
Uploads file to server. If file is a directory then directory and entire contents are uploaded.

Parameters:
file - the local file to upload
Throws:
FileTransferException - if an I/O or server related error occurs

upload

void upload(java.io.File file,
            boolean append)
            throws FileTransferException
Uploads file to server. If file is a directory then directory and entire contents are uploaded.

Parameters:
file - the local file to upload
append - true to append to remote file on server, false otherwise
Throws:
FileTransferException - if an I/O or server related error occurs

upload

void upload(java.lang.String extension,
            java.io.File file)
            throws FileTransferException
Uploads file to server with the specified temporary extension. After the file has been uploaded then the file is renamed to the original filename.

Parameters:
extension - the temporary extension to use when uploading the file
file - the file to be uploaded
Throws:
FileTransferException - if an I/O or protocol error occurs

upload

void upload(java.io.File file,
            java.lang.String remoteName)
            throws FileTransferException
Uploads file to server. If file is a directory then directory and entire contents are uploaded.

Parameters:
file - the local file to upload
remoteName - the destination filename of upload
Throws:
FileTransferException - if an I/O or server related error occurs

upload

void upload(java.io.File file,
            java.lang.String remoteName,
            boolean append)
            throws FileTransferException
Uploads file to server. If file is a directory then directory and entire contents are uploaded.

Parameters:
file - the local file to upload
remoteName - the destination filename of upload
append - true to append to remote file on server, false otherwise
Throws:
FileTransferException - if an I/O or server related error occurs

upload

void upload(java.lang.String name)
            throws FileTransferException
Uploads file to server. Uploads are performed relative to current local directory.

Parameters:
name - the local file to upload
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

upload

void upload(java.lang.String name,
            boolean append)
            throws FileTransferException
Uploads file to server. Uploads are performed relative to current local directory.

Parameters:
name - the local file to upload
append - true to append to remote file on server, false otherwise
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

upload

void upload(java.lang.String name,
            java.lang.String remoteName)
            throws FileTransferException
Uploads file to server. Uploads are performed relative to current local directory.

Parameters:
name - the local file to upload
remoteName - the destination of upload
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

upload

void upload(java.lang.String name,
            java.lang.String remoteName,
            boolean append)
            throws FileTransferException
Uploads file to server. Uploads are performed relative to current local directory.

Parameters:
name - the local file to upload
remoteName - the destination of upload
append - true to append to remote file on FTP server, false otherwise
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

resumeUpload

void resumeUpload(java.io.File file,
                  long offset)
                  throws FileTransferException
Resumes upload of file to server.

Parameters:
file - the local file to upload
offset - file offset in bytes
Throws:
FileTransferException - if an I/O or server error occurs.

resumeUpload

void resumeUpload(java.lang.String file,
                  long offset)
                  throws FileTransferException
Resumes upload of file to server.

Parameters:
file - the local file to upload
offset - file offset in bytes
Throws:
FileTransferException - if an I/O or server error occurs.

resumeUpload

void resumeUpload(java.io.File localFile,
                  java.lang.String remoteFile,
                  long off)
                  throws FileTransferException
Resume upload of file to server.

Parameters:
localFile -
remoteFile -
off -
Throws:
FileTransferException

uploadUnique

java.lang.String uploadUnique(java.lang.String fileName)
                              throws FileTransferException
Uploads the file which is created in the current directory under a name unique to that directory.

Parameters:
fileName - the file to be uploaded relative to current local directory
Returns:
the resulting unique filename on server
Throws:
FileTransferException - if an I/O or protocol error occurs.
See Also:
setLocalDir(File)

uploadUnique

java.lang.String uploadUnique(java.io.File file)
                              throws FileTransferException
Uploads the file which is created in the current directory under a name unique to that directory.

Parameters:
file - the file to be uploaded
Returns:
the resulting unique filename on server
Throws:
FileTransferException - if an I/O or protocol error occurs.

uploadUnique

java.lang.String uploadUnique(java.io.InputStream in,
                              java.lang.String fileName)
                              throws FileTransferException
Uploads the file which is created in the current directory under a name unique to that directory.

Parameters:
in - the InputStream to upload file from
fileName - the filename to be used as seed value for determining unique filename
Returns:
the resulting unique filename on server
Throws:
FileTransferException - if an I/O or protocol error occurs.

mupload

void mupload(java.util.Enumeration fileNames)
             throws FileTransferException
Uploads multiple files to server. Uploads are performed relative to current local directory.

Parameters:
fileNames - filenames of files to upload
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

mupload

void mupload(java.lang.String filter)
             throws FileTransferException
Uploads multiple files matching regular expression to server's current directory. Uploads are performed relative to current local directory. For example, to upload all files with extension .txt you may use the regular expression ".*\\.txt".

Parameters:
filter - the regular expression to use
Throws:
FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

uploadDir

void uploadDir(java.io.File localDir)
               throws FileTransferException
Uploads local directory and contents recursively to server. Uploads are stored relative to current remote directory.

Parameters:
localDir - the directory to upload
Throws:
FileTransferException - if an I/O or protocol error occurs.

uploadDir

void uploadDir(java.io.File localDir,
               java.lang.String extension)
               throws FileTransferException
Uploads local directory and contents recursively to server. Uploads are stored relative to current remote directory. Files are uploaded with the extension specified in the argument extension but when the upload has finished the remote file name is renamed to the original file name.

Parameters:
localDir - the directory to upload
extension - The extension file name used to upload each file
Throws:
FileTransferException - if an I/O or protocol error occurs.

uploadDir

void uploadDir(java.io.File localDir,
               int retryLimit,
               boolean performChecksum,
               java.lang.String extension)
               throws FileTransferException
Uploads local directory and contents. Uploads are stored relative to current remote directory.

Parameters:
localDir - the directory to upload
retryLimit - retry number when an error occurs
performChecksum - whether or not to perform checksum verification
extension - the temporary extension which will be used when uploading files or null to use current extension
Throws:
FileTransferException - if an I/O or protocol related error occurs.

uploadDir

void uploadDir(java.io.File localDir,
               int retryLimit,
               boolean performChecksum,
               java.lang.String extension,
               int threadCount)
               throws FileTransferException
Uploads local directory and contents. Uploads are stored relative to current remote directory.

Parameters:
localDir - the directory to upload
retryLimit - retry number when an error occurs
performChecksum - whether or not to perform checksum verification
extension - the temporary extension which will be used when uploading files or null to use current extension
threadCount -
Throws:
FileTransferException - if an I/O or protocol related error occurs.

getInputStream

java.io.InputStream getInputStream(java.lang.String remoteFile,
                                   long pos)
                                   throws FileTransferException
Gets InputStream for remote file for reading.

Parameters:
remoteFile - the remote file to get InputStream for
pos - the byte offset, 0 to get full file
Returns:
an InputStream
Throws:
FileTransferException - if an I/O or protocol related error occurs

getOutputStream

java.io.OutputStream getOutputStream(java.lang.String fileName,
                                     long off,
                                     boolean append)
                                     throws FileTransferException
Gets OutputStream for writing to remote file.

Parameters:
fileName - the remote filename
off - the byte offset, 0 to write at beginning of file
append - true to append to remote file, false otherwise
Returns:
an OutputStream
Throws:
FileTransferException - if an I/O or protocol related error occurs

interrupt

void interrupt()
Interrupts the current data transfer and sets interrupted flag to true. After invoking this method you must reset the interrupted flag to false. before transferring any files.

See Also:
reset()

reset

void reset()
Resets the interrupted flag to false. This method should be invoked if you have interrupted a transfer using the interrupt method and wish to resume transfering files.

See Also:
interrupt()

interrupted

boolean interrupted()
Checks if transfer process was interrupted.

Returns:
true if transfer process was interrupted.

abortUploadThread

void abortUploadThread(java.lang.String file)
Abort upload thread.

Parameters:
file -

abortDownloadThread

void abortDownloadThread(java.lang.String file)
Abort download thread.

Parameters:
file -

abortUploadThreads

void abortUploadThreads()
Abort all upload threads. Used by the implementing classes Sftp, Ftp, Ftps to abort all spawned threads.


abortDownloadThreads

void abortDownloadThreads()
Abort all download threads. Used by the implementing classes Sftp, Ftp, Ftps to abort all spawned threads.


Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved