com.enterprisedt.net.ftp
Interface FTPClientInterface

All Known Implementing Classes:
FTPClient

public interface FTPClientInterface

Defines operations in common with a number of FTP implementations.

Version:
$Revision: 1.4 $
Author:
Hans Andersen

Method Summary
 void cdup()
          Change the remote working directory to the parent directory
 void chdir(java.lang.String dir)
          Change the remote working directory to that supplied
 void connect()
          Connects to the server at the address and port number defined in the constructor.
 void delete(java.lang.String remoteFile)
          Delete the specified remote file
 java.lang.String[] dir()
          List current directory's contents as an array of strings of filenames.
 java.lang.String[] dir(java.lang.String dirname)
          List a directory's contents as an array of strings of filenames.
 java.lang.String[] dir(java.lang.String dirname, boolean full)
          List a directory's contents as an array of strings.
 FTPFile[] dirDetails(java.lang.String dirname)
          List a directory's contents as an array of FTPFile objects.
 void get(java.io.OutputStream destStream, java.lang.String remoteFile)
          Get data from the FTP server.
 byte[] get(java.lang.String remoteFile)
          Get data from the FTP server.
 void get(java.lang.String localPath, java.lang.String remoteFile)
          Get data from the FTP server.
 long getMonitorInterval()
          Get the bytes transferred between each callback on the progress monitor
 java.lang.String getRemoteHost()
          Returns the IP address or name of the remote host.
 int getRemotePort()
          Returns the port being connected to on the remote server.
 int getTimeout()
          Get the TCP timeout on the underlying socket(s).
 FTPTransferType getType()
          Get the current transfer type
 void mkdir(java.lang.String dir)
          Create the specified remote working directory
 java.util.Date modtime(java.lang.String remoteFile)
          Get modification time for a remote file
 void put(byte[] bytes, java.lang.String remoteFile)
          Put data onto the FTP server.
 void put(java.io.InputStream srcStream, java.lang.String remoteFile)
          Put a stream of data onto the FTP server.
 void put(java.lang.String localPath, java.lang.String remoteFile)
          Put a local file onto the FTP server.
 java.lang.String pwd()
          Get the current remote working directory
 void quit()
          Quit the FTP session
 void rename(java.lang.String from, java.lang.String to)
          Rename a file or directory
 void rmdir(java.lang.String dir)
          Delete the specified remote working directory
 void setProgressMonitor(FTPProgressMonitor monitor)
          Set a progress monitor for callbacks.
 void setProgressMonitor(FTPProgressMonitor monitor, long interval)
          Set a progress monitor for callbacks.
 void setRemoteHost(java.lang.String remoteHost)
          Set the IP address or name of the remote host This may only be done if the client is not already connected to the server.
 void setRemotePort(int remotePort)
          Set the port to connect to on the remote server.
 void setTimeout(int millis)
          Set the TCP timeout on the underlying socket(s).
 void setType(FTPTransferType type)
          Set the transfer type
 long size(java.lang.String remoteFile)
          Get the size of a remote file.
 

Method Detail

getRemoteHost

public java.lang.String getRemoteHost()
Returns the IP address or name of the remote host.

Returns:
Returns the remote host.

setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)
                   throws java.io.IOException,
                          FTPException
Set the IP address or name of the remote host This may only be done if the client is not already connected to the server.

Parameters:
remoteHost - The IP address or name of the remote host
Throws:
FTPException - Thrown if the client is already connected to the server.
java.io.IOException

getRemotePort

public int getRemotePort()
Returns the port being connected to on the remote server.

Returns:
Returns the port being connected to on the remote server.

setRemotePort

public void setRemotePort(int remotePort)
                   throws FTPException
Set the port to connect to on the remote server. Can only do this if not already connected.

Parameters:
remotePort - The port to use.
Throws:
FTPException - Thrown if the client is already connected to the server.

getTimeout

public int getTimeout()
Get the TCP timeout on the underlying socket(s). A value of 0 (the default) means that there are no timeouts.

Returns:
timeout that is used, in milliseconds

setTimeout

public void setTimeout(int millis)
                throws java.io.IOException,
                       FTPException
Set the TCP timeout on the underlying socket(s). Timeouts should be set before connections are made. If a timeout is set, then any operation which takes longer than the timeout value will be killed with a java.io.InterruptedException. The default is 0 meaning that the connection never times out.

Parameters:
millis - The length of the timeout, in milliseconds
Throws:
java.io.IOException
FTPException

setProgressMonitor

public void setProgressMonitor(FTPProgressMonitor monitor,
                               long interval)
Set a progress monitor for callbacks. The bytes transferred in between callbacks is only indicative. In many cases, the data is read in chunks, and if the interval is set to be smaller than the chunk size, the callback will occur after after chunk transfer rather than the interval.

Parameters:
monitor - the monitor object
interval - bytes transferred in between callbacks

setProgressMonitor

public void setProgressMonitor(FTPProgressMonitor monitor)
Set a progress monitor for callbacks. Uses default callback interval

Parameters:
monitor - the monitor object

getMonitorInterval

public long getMonitorInterval()
Get the bytes transferred between each callback on the progress monitor

Returns:
long bytes to be transferred before a callback

connect

public void connect()
             throws java.io.IOException,
                    FTPException
Connects to the server at the address and port number defined in the constructor.

Throws:
java.io.IOException - Thrown if there is a TCP/IP-related error.
FTPException - Thrown if there is an error related to the FTP protocol.

size

public long size(java.lang.String remoteFile)
          throws java.io.IOException,
                 FTPException
Get the size of a remote file. This is not a standard FTP command, it is defined in "Extensions to FTP", a draft RFC (draft-ietf-ftpext-mlst-16.txt)

Parameters:
remoteFile - name or path of remote file in current directory
Returns:
size of file in bytes
Throws:
java.io.IOException
FTPException

getType

public FTPTransferType getType()
Get the current transfer type

Returns:
the current type of the transfer, i.e. BINARY or ASCII

setType

public void setType(FTPTransferType type)
             throws java.io.IOException,
                    FTPException
Set the transfer type

Parameters:
type - the transfer type to set the server to
Throws:
java.io.IOException
FTPException

put

public void put(java.lang.String localPath,
                java.lang.String remoteFile)
         throws java.io.IOException,
                FTPException
Put a local file onto the FTP server. It is placed in the current directory.

Parameters:
localPath - path of the local file
remoteFile - name of remote file in current directory
Throws:
java.io.IOException
FTPException

put

public void put(java.io.InputStream srcStream,
                java.lang.String remoteFile)
         throws java.io.IOException,
                FTPException
Put a stream of data onto the FTP server. It is placed in the current directory.

Parameters:
srcStream - input stream of data to put
remoteFile - name of remote file in current directory
Throws:
java.io.IOException
FTPException

put

public void put(byte[] bytes,
                java.lang.String remoteFile)
         throws java.io.IOException,
                FTPException
Put data onto the FTP server. It is placed in the current directory.

Parameters:
bytes - array of bytes
remoteFile - name of remote file in current directory
Throws:
java.io.IOException
FTPException

get

public void get(java.lang.String localPath,
                java.lang.String remoteFile)
         throws java.io.IOException,
                FTPException
Get data from the FTP server. Uses the currently set transfer mode.

Parameters:
localPath - local file to put data in
remoteFile - name of remote file in current directory
Throws:
java.io.IOException
FTPException

get

public void get(java.io.OutputStream destStream,
                java.lang.String remoteFile)
         throws java.io.IOException,
                FTPException
Get data from the FTP server. Uses the currently set transfer mode.

Parameters:
destStream - data stream to write data to
remoteFile - name of remote file in current directory
Throws:
java.io.IOException
FTPException

get

public byte[] get(java.lang.String remoteFile)
           throws java.io.IOException,
                  FTPException
Get data from the FTP server. Transfers in whatever mode we are in. Retrieve as a byte array. Note that we may experience memory limitations as the entire file must be held in memory at one time.

Parameters:
remoteFile - name of remote file in current directory
Throws:
java.io.IOException
FTPException

dirDetails

public FTPFile[] dirDetails(java.lang.String dirname)
                     throws java.io.IOException,
                            FTPException,
                            java.text.ParseException
List a directory's contents as an array of FTPFile objects. Should work for Windows and most Unix FTP servers - let us know about unusual formats (http://www.enterprisedt.com/forums/index.php)

Parameters:
dirname - name of directory OR filemask
Returns:
an array of FTPFile objects
Throws:
java.io.IOException
FTPException
java.text.ParseException

dir

public java.lang.String[] dir()
                       throws java.io.IOException,
                              FTPException
List current directory's contents as an array of strings of filenames.

Returns:
an array of current directory listing strings
Throws:
java.io.IOException
FTPException

dir

public java.lang.String[] dir(java.lang.String dirname)
                       throws java.io.IOException,
                              FTPException
List a directory's contents as an array of strings of filenames.

Parameters:
dirname - name of directory OR filemask
Returns:
an array of directory listing strings
Throws:
java.io.IOException
FTPException

dir

public java.lang.String[] dir(java.lang.String dirname,
                              boolean full)
                       throws java.io.IOException,
                              FTPException
List a directory's contents as an array of strings. A detailed listing is available, otherwise just filenames are provided. The detailed listing varies in details depending on OS and FTP server. Note that a full listing can be used on a file name to obtain information about a file

Parameters:
dirname - name of directory OR filemask
full - true if detailed listing required false otherwise
Returns:
an array of directory listing strings
Throws:
java.io.IOException
FTPException

delete

public void delete(java.lang.String remoteFile)
            throws java.io.IOException,
                   FTPException
Delete the specified remote file

Parameters:
remoteFile - name of remote file to delete
Throws:
java.io.IOException
FTPException

rename

public void rename(java.lang.String from,
                   java.lang.String to)
            throws java.io.IOException,
                   FTPException
Rename a file or directory

Parameters:
from - name of file or directory to rename
to - intended name
Throws:
java.io.IOException
FTPException

rmdir

public void rmdir(java.lang.String dir)
           throws java.io.IOException,
                  FTPException
Delete the specified remote working directory

Parameters:
dir - name of remote directory to delete
Throws:
java.io.IOException
FTPException

mkdir

public void mkdir(java.lang.String dir)
           throws java.io.IOException,
                  FTPException
Create the specified remote working directory

Parameters:
dir - name of remote directory to create
Throws:
java.io.IOException
FTPException

chdir

public void chdir(java.lang.String dir)
           throws java.io.IOException,
                  FTPException
Change the remote working directory to that supplied

Parameters:
dir - name of remote directory to change to
Throws:
java.io.IOException
FTPException

cdup

public void cdup()
          throws java.io.IOException,
                 FTPException
Change the remote working directory to the parent directory

Throws:
java.io.IOException
FTPException

modtime

public java.util.Date modtime(java.lang.String remoteFile)
                       throws java.io.IOException,
                              FTPException
Get modification time for a remote file

Parameters:
remoteFile - name of remote file
Returns:
modification time of file as a date
Throws:
java.io.IOException
FTPException

pwd

public java.lang.String pwd()
                     throws java.io.IOException,
                            FTPException
Get the current remote working directory

Returns:
the current working directory
Throws:
java.io.IOException
FTPException

quit

public void quit()
          throws java.io.IOException,
                 FTPException
Quit the FTP session

Throws:
java.io.IOException
FTPException


Copyright (c) 2001-2004 Enterprise Distributed Technologies Ltd. All Rights Reserved.