Secure iNet Factory

com.jscape.filetransfer
Interface FileTransfer

All Known Implementing Classes:
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 addFileTransferListener(FileTransferListener listener)
          Adds FileTransferListener.
 void clearProxySettings()
          Clears proxy server values.
 void connect()
          Connects to server and performs login.
 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.
 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 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.lang.String file, long offset)
          Resumes upload of file to server.
 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 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 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(int timeout)
          Sets the timeout for opening connection to server.
 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, 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

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

See Also:
getMode(), Constant Field Values

ASCII

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

See Also:
getMode(), Constant Field Values

BINARY

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

See Also:
getMode(), Constant Field Values

CURRENT_DIR

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

See Also:
Constant Field Values

UP_DIR

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

See Also:
Constant Field Values
Method Detail

connect

public void connect()
             throws com.jscape.filetransfer.FileTransferException
Connects to server and performs login.

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

deleteDir

public void deleteDir(java.lang.String name)
               throws com.jscape.filetransfer.FileTransferException
Deletes directory from server.

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

deleteDir

public void deleteDir(java.lang.String name,
                      boolean recursive)
               throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.

deleteFile

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

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

disconnect

public void disconnect()
                throws com.jscape.filetransfer.FileTransferException
Quits session and disconnects from server.

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

download

public void download(java.io.OutputStream out,
                     java.lang.String remoteFile)
              throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.

download

public java.io.File download(java.lang.String remoteFile)
                      throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

download

public java.io.File download(java.lang.String localFile,
                             java.lang.String remoteFile)
                      throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

downloadDir

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

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

downloadDir

public void downloadDir(java.lang.String remoteDir,
                        int retryLimit,
                        boolean performChecksum)
                 throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol error occurs.

getDebug

public boolean getDebug()
Gets debugging state.

Returns:
true if debugging is on

getDebugStream

public 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

getDir

public java.lang.String getDir()
                        throws com.jscape.filetransfer.FileTransferException
Gets current working directory of server.

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

getDirListing

public java.util.Enumeration getDirListing()
                                    throws com.jscape.filetransfer.FileTransferException
Gets directory listing from server.

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

getDirListing

public java.util.Enumeration getDirListing(java.lang.String filter)
                                    throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.
See Also:
getDirListingAsString(String), getNameListing()

getDirListingAsString

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

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

getDirListingAsString

public java.lang.String getDirListingAsString(java.lang.String filter)
                                       throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.

getFilesize

public long getFilesize(java.lang.String remoteFile)
                 throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol error occurs.

getFileTimestamp

public java.util.Date getFileTimestamp(java.lang.String remoteFile)
                                throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.

setFileTimestamp

public void setFileTimestamp(java.lang.String remoteFile,
                             java.util.Date dateFile)
                      throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.

getHostname

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

Returns:
hostname

getLocalDir

public 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

getLocalDirListing

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

Returns:
an java.util.Enumeration of File

getMode

public 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

getNameListing

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

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

getNameListing

public java.util.Enumeration getNameListing(java.lang.String filter)
                                     throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server related error occurs

getPassive

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

Returns:
true if passive mode is used, false otherwise

getPassword

public java.lang.String getPassword()
Gets password.

Returns:
the password

getPort

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

Returns:
server port

getTimeout

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

Returns:
timeout in milliseconds

getUsername

public java.lang.String getUsername()
Gets username.

Returns:
username

setWireEncoding

public 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

getWireEncoding

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

Returns:
Returns the encoding is being used

interrupt

public 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()

interrupted

public boolean interrupted()
Checks if transfer process was interrupted.

Returns:
true if transfer process was interrupted.

isConnected

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

Returns:
true if connected false otherwise

makeDir

public void makeDir(java.lang.String name)
             throws com.jscape.filetransfer.FileTransferException
Makes directory on server.

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

makeDirRecursive

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

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

makeLocalDir

public 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()

mdelete

public void mdelete(java.lang.String filter)
             throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an error occurs.

mdownload

public void mdownload(java.util.Enumeration fileNames)
               throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File), downloadDir(String)

mdownload

public void mdownload(java.lang.String filter)
               throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File), downloadDir(java.lang.String)

mupload

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

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

mupload

public void mupload(java.lang.String filter)
             throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

renameFile

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

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

reset

public 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()

resumeDownload

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

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

resumeDownload

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

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

resumeUpload

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

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

resumeUpload

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

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

setAscii

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

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

setAuto

public void setAuto(boolean auto)
             throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.

setBinary

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

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

setDebug

public 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)

setDebugStream

public 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

setDir

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

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

setDirUp

public void setDirUp()
              throws com.jscape.filetransfer.FileTransferException
Sets current directory on server to parent directory.

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

setHostname

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

Parameters:
host - the hostname or IP address of server

setLocalDir

public 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

setPassive

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

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

setPassword

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

Parameters:
password - the password

setPort

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

Parameters:
port - the port

setTimeout

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

Parameters:
timeout - the timeout in milliseconds

setUsername

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

Parameters:
username - the username

upload

public void upload(byte[] data,
                   java.lang.String name)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server related error occurs

upload

public void upload(byte[] data,
                   java.lang.String name,
                   boolean append)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server related error occurs

upload

public void upload(java.io.File file)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server related error occurs

upload

public void upload(java.io.File file,
                   boolean append)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server related error occurs

upload

public void upload(java.lang.String extension,
                   java.io.File file)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol error occurs

upload

public void upload(java.io.File file,
                   java.lang.String remoteName)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server related error occurs

upload

public void upload(java.io.File file,
                   java.lang.String remoteName,
                   boolean append)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server related error occurs

upload

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

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

upload

public void upload(java.lang.String name,
                   boolean append)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

upload

public void upload(java.lang.String name,
                   java.lang.String remoteName)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

upload

public void upload(java.lang.String name,
                   java.lang.String remoteName,
                   boolean append)
            throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or server error occurs.
See Also:
setLocalDir(java.io.File)

uploadUnique

public java.lang.String uploadUnique(java.lang.String fileName)
                              throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol error occurs.
See Also:
setLocalDir(File)

uploadUnique

public java.lang.String uploadUnique(java.io.File file)
                              throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol error occurs.

uploadUnique

public java.lang.String uploadUnique(java.io.InputStream in,
                                     java.lang.String fileName)
                              throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol error occurs.

uploadDir

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

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

uploadDir

public void uploadDir(java.io.File localDir,
                      java.lang.String extension)
               throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol error occurs.

uploadDir

public void uploadDir(java.io.File localDir,
                      int retryLimit,
                      boolean performChecksum,
                      java.lang.String extension)
               throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol related error occurs.

addFileTransferListener

public void addFileTransferListener(FileTransferListener listener)
Adds FileTransferListener.

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

setBlockTransferSize

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

Parameters:
blocksize - the blocksize in bytes

getBlockTransferSize

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

Returns:
blocksize in bytes

removeFileTransferListener

public void removeFileTransferListener(FileTransferListener listener)
Removes specified FileTransferListener.

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

setProxyHost

public 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

public 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

public 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

public void clearProxySettings()
Clears proxy server values.


getInputStream

public java.io.InputStream getInputStream(java.lang.String remoteFile,
                                          long pos)
                                   throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol related error occurs

getImplementation

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

Returns:
an instance of Ftp, Ftps or Sftp
See Also:
Ftp, Ftps, com.jscpae.inet.sftp.Sftp

getOutputStream

public java.io.OutputStream getOutputStream(java.lang.String fileName,
                                            long off,
                                            boolean append)
                                     throws com.jscape.filetransfer.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:
com.jscape.filetransfer.FileTransferException - if an I/O or protocol related error occurs

Secure iNet Factory

Copyright JSCAPE 1999-2008 All Rights Reserved