tribble.net.ftp
Interface FTPSimpleClientI

All Known Subinterfaces:
FTPClientI
All Known Implementing Classes:
FTPClient, FTPClientAdapter, FTPSSLClient

public interface FTPSimpleClientI

Simple FTP client interface. Allows clients to establish FTP connections, send and receive files, get remote directory listings, etc.

Field Summary
static java.lang.String REV
          Revision information.
 
Method Summary
 void appendFile(java.io.File src, java.lang.String dst)
          Append (send) a file from the local system to a file on the remote FTP system.
 void appendFile(java.io.InputStream in, java.lang.String dst)
          Append (send) a file from the local system to a file on the remote FTP system.
 void connect()
          Connect to the remote FTP system.
 void createDirectory(java.lang.String dir)
          Create a directory on the remote FTP system.
 void disconnect()
          Disconnect from the remote FTP system.
 int getCommandPort()
          Retrieve the FTP command port number.
 int getDataPort()
          Retrieve the FTP data port number.
 java.util.ArrayList<java.lang.String> getDirectoryNames(java.lang.String path, java.io.FilenameFilter filt, int max)
          Get (receive) a list of filenames in a directory on the remote FTP system.
 java.util.ArrayList<java.lang.String> getDirectoryNames(java.lang.String path, int max)
          Get (receive) a list of filenames in a directory on the remote FTP system.
 void getFile(java.lang.String src, java.io.File dst)
          Get (receive) a file from the remote FTP system to the local system.
 void getFile(java.lang.String src, java.io.OutputStream out)
          Get (receive) a file from the remote FTP system to the local system.
 java.lang.String getHost()
          Retrieve the remote FTP host name.
 java.lang.String getLocalDir()
          Retrieve the working directory of the local system.
 java.lang.String getPassword()
          Retrieve the user password.
 java.lang.String getRemoteDir()
          Retrieve the working directory of the remote FTP system.
 int getTimeOut()
          Retrieve the FTP I/O time-out.
 java.lang.String getUserID()
          Retrieve the user-ID.
 boolean isConnected()
          Determine if this client is connected to the remote FTP system.
 boolean isLoggedIn()
          Determine if this client is logged to the remote FTP system.
 void login()
          Log on to the remote FTP system.
 void putFile(java.io.File src, java.lang.String dst)
          Put (send) a file from the local system to the remote FTP system.
 void putFile(java.io.InputStream in, java.lang.String dst)
          Put (send) a file from the local system to the remote FTP system.
 void removeDirectory(java.lang.String dir)
          Remove a directory on the remote FTP system.
 void removeFile(java.lang.String file)
          Remove a file on the remote FTP system.
 void rename(java.lang.String from, java.lang.String to)
          Rename a file or directory on the remote FTP system.
 int setBufferSize(int len)
          Set the size of the FTP data transfer buffer.
 void setCommandPort(int port)
          Set the remote FTP command port number.
 void setDataPort(int port)
          Set the remote FTP data port number.
 void setHost(java.lang.String host)
          Set the remote FTP host (system) name.
 void setLocalDir(java.lang.String dir)
          Set the working directory on the local system.
 boolean setPassive(boolean flag)
          Set this FTP client to operate (or not) in passive data transfer mode.
 void setPassword(java.lang.String pwd)
          Set the user password.
 java.lang.String setRemoteDir(java.lang.String dir)
          Set the working directory on the remote FTP system.
 java.lang.String setRemoteDirUp()
          Set the working directory on the remote FTP system to the parent directory of the current working directory.
 boolean setTextMode(boolean flag)
          Set the transfer mode to text (ASCII) or binary.
 void setTimeOut(int secs)
          Set the remote FTP I/O time-out.
 void setUserID(java.lang.String id)
          Set the user name (user-ID).
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values
Method Detail

getHost

java.lang.String getHost()
Retrieve the remote FTP host name.

Returns:
FTP system host name or IP address.
Since:
1.1, 2001-04-14
See Also:
setHost()

setHost

void setHost(java.lang.String host)
Set the remote FTP host (system) name.

Parameters:
host - FTP system host name or IP address.
Since:
1.1, 2001-04-14
See Also:
getHost()

getCommandPort

int getCommandPort()
Retrieve the FTP command port number.

Returns:
FTP command port number.
Since:
1.1, 2006-03-22
See Also:
setCommandPort(), getDataPort()

setCommandPort

void setCommandPort(int port)
Set the remote FTP command port number.

Parameters:
port - FTP command port number. (The default FTP port is 21.)
Since:
1.1, 2006-03-22
See Also:
getCommandPort(), setDataPort()

getDataPort

int getDataPort()
Retrieve the FTP data port number.

Returns:
FTP data port number.
Since:
1.1, 2006-03-22
See Also:
setDataPort(), getCommandPort()

setDataPort

void setDataPort(int port)
Set the remote FTP data port number.

Parameters:
port - FTP data port number. Setting this to zero or a negative number causes the data ports to be chosen (randomly) by the local system when operating in non-passive mode. (The default FTP port is 0.)
Since:
1.1, 2006-03-22
See Also:
getDataPort(), setCommandPort()

getTimeOut

int getTimeOut()
Retrieve the FTP I/O time-out.

Returns:
FTP I/O time-out, in seconds.
Since:
1.1, 2006-06-02
See Also:
setTimeOut(), getCommandPort(), getDataPort()

setTimeOut

void setTimeOut(int secs)
Set the remote FTP I/O time-out.

Parameters:
secs - FTP I/O time-out, in seconds.
Since:
1.1, 2006-06-02
See Also:
getTimeOut(), setCommandPort(), setDataPort()

setBufferSize

int setBufferSize(int len)
Set the size of the FTP data transfer buffer.

Parameters:
len - New buffer size. Values between 1K (1,024) and 16K (16,384) are probably optimal for most applications. Classes that implement this interface may choose to ignore this setting.
Returns:
The previous buffer size setting.
Throws:
java.lang.IllegalArgumentException - (unchecked) Thrown if len is less than 1.
Since:
1.5, 2008-09-18
See Also:
appendFile(), getFile(), putFile()

getUserID

java.lang.String getUserID()
Retrieve the user-ID.

Since:
1.1, 2001-04-14
See Also:
setUserID()

setUserID

void setUserID(java.lang.String id)
Set the user name (user-ID).

Parameters:
id - User-ID.
Since:
1.1, 2001-04-14
See Also:
getUserID()

getPassword

java.lang.String getPassword()
Retrieve the user password.

Returns:
User password.
Since:
1.1, 2001-04-14
See Also:
setPassword()

setPassword

void setPassword(java.lang.String pwd)
Set the user password.

Parameters:
pwd - User password.
Since:
1.1, 2001-04-14
See Also:
getPassword()

setPassive

boolean setPassive(boolean flag)
Set this FTP client to operate (or not) in passive data transfer mode. Passive mode allows the remote FTP system to assign the data ports, while non-passive mode allows the client to assign them.

Parameters:
flag - If true, the data transfer mode is set to passive, otherwise it is set to non-passive (active listen) mode.
Returns:
The previous mode setting.
Since:
1.1, 2006-03-17

connect

void connect()
             throws java.io.IOException
Connect to the remote FTP system.

Throws:
java.io.IOException - Thrown if unable to connect to the remote FTP system.
Since:
1.1, 2001-04-14
See Also:
disconnect()

disconnect

void disconnect()
Disconnect from the remote FTP system. Note that this method does not throw IOException.

Since:
1.1, 2001-04-14
See Also:
connect()

isConnected

boolean isConnected()
Determine if this client is connected to the remote FTP system.

Returns:
True if this client has connected to a remote FTP system, otherwise false.
Since:
1.1, 2006-04-06
See Also:
connect(), disconnect()

login

void login()
           throws java.io.IOException
Log on to the remote FTP system. This uses the last setting of the user-ID and password.

Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2001-04-14
See Also:
connect(), setUserID(), setPassword()

isLoggedIn

boolean isLoggedIn()
Determine if this client is logged to the remote FTP system.

Returns:
True if this client has connected and a user if logged into a remote FTP system, otherwise false.
Since:
1.1, 2006-04-06
See Also:
login()

setTextMode

boolean setTextMode(boolean flag)
Set the transfer mode to text (ASCII) or binary. In ASCII mode, files are transferred as text files, so that newline sequences (CR, LF, or CR/LF) are converted into the local native newline sequence (which is determined by the System.getProperty("line.separator") setting).

Parameters:
flag - If true, the transfer mode is set to "ASCII" (text), otherwise it is set to "binary".
Returns:
The previous mode setting.
Since:
1.4, 2007-07-26

setRemoteDir

java.lang.String setRemoteDir(java.lang.String dir)
                              throws java.io.IOException
Set the working directory on the remote FTP system.

Parameters:
dir - Remote directory name.
Returns:
The new current remote directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2001-04-14
See Also:
getRemoteDir(), setLocalDir()

setRemoteDirUp

java.lang.String setRemoteDirUp()
                                throws java.io.IOException
Set the working directory on the remote FTP system to the parent directory of the current working directory. In other words, change the directory to be one level up from the current setting.

Returns:
The new current remote directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-04-01
See Also:
getRemoteDir(), setRemoteDir(), setLocalDir()

getRemoteDir

java.lang.String getRemoteDir()
                              throws java.io.IOException
Retrieve the working directory of the remote FTP system.

Returns:
The current remote directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2001-04-14
See Also:
setRemoteDir(), getLocalDir()

setLocalDir

void setLocalDir(java.lang.String dir)
                 throws java.io.IOException
Set the working directory on the local system. Note that this does not actually change the current working directory for the Java program, but only establishes the default directory prefix to use for local files sent or received by this FTP session.

Parameters:
dir - Local directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2001-04-14
See Also:
getLocalDir(), setRemoteDir()

getLocalDir

java.lang.String getLocalDir()
                             throws java.io.IOException
Retrieve the working directory of the local system.

Returns:
The current local directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2001-04-14
See Also:
setLocalDir(), getRemoteDir()

getFile

void getFile(java.lang.String src,
             java.io.File dst)
             throws java.io.IOException
Get (receive) a file from the remote FTP system to the local system.

Parameters:
src - Remote source filename. If this does not contain a directory prefix, the current remote working directory is assumed.
dst - Local source filename. If this does not contain a directory prefix, the current local working directory is assumed. This may be null, in which case the base filename of src (without the directory prefix) is used.
Throws:
java.io.IOException - Thrown if the file could not be transmitted or if any other error occurs.
Since:
1.1, 2001-04-14
See Also:
getFile(), putFile(), appendFile()

getFile

void getFile(java.lang.String src,
             java.io.OutputStream out)
             throws java.io.IOException
Get (receive) a file from the remote FTP system to the local system.

Parameters:
src - Remote source filename. If this does not contain a directory prefix, the current remote working directory is assumed.
out - Output stream to write the contents of the file retrieved from the remote FTP system to. Note that this stream is flushed but is not closed after the contents have been transmitted.
Throws:
java.io.IOException - Thrown if the file could not be transmitted or if any other error occurs.
Since:
1.1, 2006-04-10
See Also:
getFile(), putFile(), appendFile()

putFile

void putFile(java.io.File src,
             java.lang.String dst)
             throws java.io.IOException
Put (send) a file from the local system to the remote FTP system.

Parameters:
src - Local source filename. If this does not contain a directory prefix, the current local working directory is assumed.
dst - Remote target filename. If this does not contain a directory prefix, the current remote working directory is assumed. This may be null, in which case the base filename of src (without the directory prefix) is used.
Throws:
java.io.IOException - Thrown if the file could not be transmitted or if any other error occurs.
Since:
1.1, 2001-04-14
See Also:
putFile(), appendFile(), getFile()

putFile

void putFile(java.io.InputStream in,
             java.lang.String dst)
             throws java.io.IOException
Put (send) a file from the local system to the remote FTP system.

Parameters:
in - Input stream containing the contents of the file to send to the remote FTP system. Note that this stream is not closed after the contents have been transmitted.
dst - Remote target filename. If this does not contain a directory prefix, the current remote working directory is assumed. This may be null, in which case the base filename of src (without the directory prefix) is used.
Throws:
java.io.IOException - Thrown if the file could not be transmitted or if any other error occurs.
Since:
1.1, 2006-04-10
See Also:
putFile(), appendFile(), getFile()

appendFile

void appendFile(java.io.File src,
                java.lang.String dst)
                throws java.io.IOException
Append (send) a file from the local system to a file on the remote FTP system.

Parameters:
src - Local source filename. If this does not contain a directory prefix, the current local working directory is assumed.
dst - Remote target filename. If this does not contain a directory prefix, the current remote working directory is assumed. This may be null, in which case the base filename of src (without the directory prefix) is used.
Throws:
java.io.IOException - Thrown if the file could not be transmitted or if any other error occurs.
Since:
1.3, 2007-07-21
See Also:
appendFile(), putFile(), getFile()

appendFile

void appendFile(java.io.InputStream in,
                java.lang.String dst)
                throws java.io.IOException
Append (send) a file from the local system to a file on the remote FTP system.

Parameters:
in - Input stream containing the contents of the file to send to the remote FTP system. Note that this stream is not closed after the contents have been transmitted.
dst - Remote target filename. If this does not contain a directory prefix, the current remote working directory is assumed. This may be null, in which case the base filename of src (without the directory prefix) is used.
Throws:
java.io.IOException - Thrown if the file could not be transmitted or if any other error occurs.
Since:
1.3, 2007-07-21
See Also:
appendFile(), putFile(), getFile()

getDirectoryNames

java.util.ArrayList<java.lang.String> getDirectoryNames(java.lang.String path,
                                                        int max)
                                                        throws java.io.IOException
Get (receive) a list of filenames in a directory on the remote FTP system.

Parameters:
path - The remote directory or filename to list. If this is empty (""), the current remote working directory is assumed.
max - Maximum number of filenames to list. A value of zero (0) specifies that there is no maximum.
Returns:
A vector of Strings containing the filenames in the remote directory.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2007-02-28

getDirectoryNames

java.util.ArrayList<java.lang.String> getDirectoryNames(java.lang.String path,
                                                        java.io.FilenameFilter filt,
                                                        int max)
                                                        throws java.io.IOException
Get (receive) a list of filenames in a directory on the remote FTP system.

Parameters:
path - The remote directory or filename to list. If this is empty (""), the current remote working directory is assumed.
filt - Filer to apply to the filenames. Only filenames that are accepted by the filter will appear in the returned vector. If this is null, no filtering is applied to the filenames. This object's accept() method is called for each filename in the directory, being passed a null directory (first argument) and the found filename (second argument).
max - Maximum number of filenames to return. A value of zero (0) specifies that there is no maximum.
Returns:
A vector of Strings containing the filenames in the remote directory.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.2, 2007-04-15

rename

void rename(java.lang.String from,
            java.lang.String to)
            throws java.io.IOException
Rename a file or directory on the remote FTP system.

Parameters:
from - Old (existing) remote file or directory name to rename.
to - New name to rename the remote file or directory to.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-03-16

removeFile

void removeFile(java.lang.String file)
                throws java.io.IOException
Remove a file on the remote FTP system.

Parameters:
file - Name of the file to delete. If this specifies a relative filename, the file is assumed to be located in the current remote working directory.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-03-16

createDirectory

void createDirectory(java.lang.String dir)
                     throws java.io.IOException
Create a directory on the remote FTP system.

Parameters:
dir - Name of the directory to create. If this specifies a relative directory name, the directory is created in the current remote working directory.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-03-16

removeDirectory

void removeDirectory(java.lang.String dir)
                     throws java.io.IOException
Remove a directory on the remote FTP system.

Parameters:
dir - Name of the directory to delete. If this specifies a relative directory name, the directory is assumed to be located in the current remote working directory.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-03-16