tribble.net.ftp
Class FTPClientAdapter

java.lang.Object
  extended by tribble.net.ftp.FTPClientAdapter
All Implemented Interfaces:
FTPClientI, FTPSimpleClientI
Direct Known Subclasses:
FTPClient

public abstract class FTPClientAdapter
extends java.lang.Object
implements FTPClientI

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

This base class provides a framework upon which to build working FTP client implementations.

References

IETF RFC 959 - File Transfer Protocol (FTP)
www.ietf.org/rfc/rfc0959.txt.

Source code:
Available at: http://david.tribble.com/src/java/tribble/net/ftp/FTPClientAdapter.java
Documentation:
Available at: http://david.tribble.com/docs/tribble/net/ftp/FTPClientAdapter.html

Since:
API 1.0, 2006-04-14
Version:
API 2.0 $Revision: 1.13 $ $Date: 2010/07/12 21:26:02 $
Author:
David R. Tribble (david@tribble.com).

Copyright ©2006-2010 by David R. Tribble, all rights reserved.
Permission is granted to any person or entity except those designated by the United States Department of State as a terrorist, or terrorist government or agency, to use and distribute this source code provided that the original copyright notice remains present and unaltered.

See Also:
FTPClient

Field Summary
protected  int m_bufSize
          Data transfer buffer length.
protected  int m_cmdPort
          Remote FTP port number.
protected  int m_dataPort
           
 java.io.PrintStream m_debugOut
          Enable debug tracing.
protected  java.lang.String m_hostName
          Remote FTP host name.
protected  long m_inBytes
          Number of input bytes read.
protected  boolean m_isConnected
          This session has connected to the remote FTP system.
protected  boolean m_isLoggedOn
          FTP user is logged into the FTP session.
protected  java.io.File m_localDir
          Current local working directory.
protected  long m_outBytes
          Number of output bytes written.
protected  boolean m_passiveMode
          Transfer mode is passive.
protected  java.lang.String m_password
          User password.
protected  java.lang.String m_remoteDir
          Current remote working directory.
protected  boolean m_stop
          Stop/interrupt execution flag.
protected  boolean m_textMode
          Transfer files as text (ASCII) mode, not binary.
protected  int m_timeOut
          I/O time-out (seconds).
protected  java.lang.String m_userID
          User-ID.
 
Constructor Summary
FTPClientAdapter()
          Default constructor.
 
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.
abstract  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 appendFile(java.lang.String src, java.lang.String dst)
          Append (send) a file from the local system to a file on the remote FTP system.
abstract  void connect()
          Connect to the remote FTP system.
abstract  void createDirectory(java.lang.String dir)
          Create a directory on the remote FTP system.
abstract  void disconnect()
          Disconnect from the remote FTP system.
protected  void finalize()
          Finalization.
 int getCommandPort()
          Retrieve the FTP command port number.
 int getDataPort()
          Retrieve the FTP data port number.
abstract  void getDirectoryList(java.lang.String path, int max, java.io.OutputStream out)
          Get (receive) a directory listing from the remote FTP system.
 void getDirectoryList(java.lang.String path, java.io.OutputStream out)
          Get (receive) a directory listing from the remote FTP system.
 java.util.ArrayList<java.lang.String> getDirectoryNames(java.lang.String path)
          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.
abstract  void getDirectoryNames(java.lang.String path, int max, java.io.OutputStream out)
          Get (receive) a list of filenames in a directory on the remote FTP system.
 void getDirectoryNames(java.lang.String path, java.io.OutputStream out)
          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.
abstract  void getFile(java.lang.String src, java.io.OutputStream out)
          Get (receive) a file from the remote FTP system to the local system.
 void getFile(java.lang.String src, java.lang.String dst)
          Get (receive) a file from the remote FTP system to the local system.
abstract  void getHelp(java.io.OutputStream out)
          Get (receive) a help listing of supported FTP commands from the remote FTP system.
 java.lang.String getHost()
          Retrieve the remote FTP host name.
 long getInputByteCount()
          Retrieve the number of bytes read from the input data port so far.
 java.lang.String getLocalDir()
          Retrieve the working directory of the local system.
 long getOutputByteCount()
          Retrieve the number of bytes written to the output data port so far.
 java.lang.String getPassword()
          Retrieve the user password.
 java.lang.String getRemoteDir()
          Retrieve the current working directory of the remote FTP system.
abstract  void getStatus(java.io.OutputStream out)
          Retrieve the current status of the remote FTP system.
abstract  void getSystemInfo(java.io.OutputStream out)
          Retrieve the identity information of the remote FTP system.
 int getTimeOut()
          Retrieve the FTP I/O time-out.
 java.lang.String getUserID()
          Retrieve the user-ID.
static boolean isAbsoluteFilename(java.io.File file)
          Determine if a filename is absolute or not.
 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.
abstract  void login(java.lang.String user, java.lang.String pwd)
          Log on to the remote FTP system.
abstract  void ping()
          Pings 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.
abstract  void putFile(java.io.InputStream in, java.lang.String dst)
          Put (send) a file from the local system to the remote FTP system.
 void putFile(java.lang.String src, java.lang.String dst)
          Put (send) a file from the local system to the remote FTP system.
abstract  void removeDirectory(java.lang.String dir)
          Remove a directory on the remote FTP system.
abstract  void removeFile(java.lang.String file)
          Remove a file on the remote FTP system.
abstract  void rename(java.lang.String from, java.lang.String to)
          Rename a file or directory on the remote FTP system.
 void resetStop()
          Reset the interrupt signal set by a previous call to stop().
 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.
abstract  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).
 void stop()
          Signal the current FTP operation to be interrupted and to terminate prematurely.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface tribble.net.ftp.FTPSimpleClientI
getDirectoryNames
 

Field Detail

m_debugOut

public java.io.PrintStream m_debugOut
Enable debug tracing.


m_hostName

protected java.lang.String m_hostName
Remote FTP host name.


m_cmdPort

protected int m_cmdPort
Remote FTP port number.


m_dataPort

protected int m_dataPort

m_timeOut

protected int m_timeOut
I/O time-out (seconds).


m_bufSize

protected int m_bufSize
Data transfer buffer length.


m_userID

protected java.lang.String m_userID
User-ID.


m_password

protected java.lang.String m_password
User password.


m_remoteDir

protected java.lang.String m_remoteDir
Current remote working directory.


m_localDir

protected java.io.File m_localDir
Current local working directory.


m_passiveMode

protected boolean m_passiveMode
Transfer mode is passive.


m_textMode

protected boolean m_textMode
Transfer files as text (ASCII) mode, not binary.


m_isConnected

protected boolean m_isConnected
This session has connected to the remote FTP system.


m_isLoggedOn

protected boolean m_isLoggedOn
FTP user is logged into the FTP session.


m_stop

protected volatile boolean m_stop
Stop/interrupt execution flag.


m_inBytes

protected volatile long m_inBytes
Number of input bytes read.


m_outBytes

protected volatile long m_outBytes
Number of output bytes written.

Constructor Detail

FTPClientAdapter

public FTPClientAdapter()
Default constructor.

Since:
1.1, 2006-04-14
Method Detail

isAbsoluteFilename

public static boolean isAbsoluteFilename(java.io.File file)
Determine if a filename is absolute or not.

Note that this handles Win32 absolute pathnames without leading drive letters properly (e.g., "c:\foo.txt" and "\foo.txt" are both absolute pathnames). This corrects an oversight in the standard Java library implementation.

Parameters:
file - A filename to check.
Returns:
True if the file is an absolute pathname, otherwise false.
Since:
1.12, 2010-07-11

stop

public void stop()
Signal the current FTP operation to be interrupted and to terminate prematurely.

Once this method has been called, the interrupt signal can be cleared by calling resetStop().

Since:
1.7, 2006-05-06
See Also:
resetStop()

resetStop

public void resetStop()
Reset the interrupt signal set by a previous call to stop().

Since:
1.7, 2006-05-06
See Also:
stop()

getInputByteCount

public long getInputByteCount()
Retrieve the number of bytes read from the input data port so far.

This method can be called from a separate thread while an FTP operation is being performed on this object to check the progress of the operation.

Returns:
The number of bytes read from the data port so far during the current FTP operation.
Since:
API 2.0, 1.13, 2010-07-12

getOutputByteCount

public long getOutputByteCount()
Retrieve the number of bytes written to the output data port so far.

This method can be called from a separate thread while an FTP operation is being performed on this object to check the progress of the operation.

Returns:
The number of bytes written to the data port so far during the current FTP operation.
Since:
API 2.0, 1.13, 2010-07-12

getHost

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

Specified by:
getHost in interface FTPSimpleClientI
Returns:
FTP system host name or IP address.
Since:
1.1, 2006-04-14
See Also:
setHost()

setHost

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

Specified by:
setHost in interface FTPSimpleClientI
Parameters:
host - FTP system host name or IP address.
Since:
1.1, 2006-04-14
See Also:
getHost()

getCommandPort

public int getCommandPort()
Retrieve the FTP command port number.

Specified by:
getCommandPort in interface FTPSimpleClientI
Returns:
FTP command port number.
Since:
1.1, 2006-04-14
See Also:
setCommandPort(), getDataPort()

setCommandPort

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

Specified by:
setCommandPort in interface FTPSimpleClientI
Parameters:
port - FTP command port number. (The default FTP port is 21.)
Since:
1.1, 2006-04-14
See Also:
getCommandPort(), setDataPort()

getDataPort

public int getDataPort()
Retrieve the FTP data port number.

Specified by:
getDataPort in interface FTPSimpleClientI
Returns:
FTP data port number.
Since:
1.1, 2006-04-14
See Also:
setDataPort(), getCommandPort()

setDataPort

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

Specified by:
setDataPort in interface FTPSimpleClientI
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-04-14
See Also:
getDataPort(), setCommandPort()

getTimeOut

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

Specified by:
getTimeOut in interface FTPSimpleClientI
Returns:
FTP I/O time-out, in seconds.
Since:
1.2, 2006-06-02
See Also:
setTimeOut(), getCommandPort(), getDataPort()

setTimeOut

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

Specified by:
setTimeOut in interface FTPSimpleClientI
Parameters:
secs - FTP I/O time-out, in seconds. (The default setting is 30.)
Since:
1.2, 2006-06-02
See Also:
getTimeOut(), setCommandPort(), setDataPort()

setBufferSize

public int setBufferSize(int len)
Set the size of the FTP data transfer buffer. By default, the internal buffer length is 8K (8,192) bytes.

Specified by:
setBufferSize in interface FTPSimpleClientI
Parameters:
len - New buffer size. Values between 1K (1,024) and 16K (16,384) are probably optimal for most applications. Classes that extend this class 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.11, 2008-09-18
See Also:
appendFile(), getFile(), putFile()

getUserID

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

Specified by:
getUserID in interface FTPSimpleClientI
Since:
1.1, 2006-04-14
See Also:
setUserID()

setUserID

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

Specified by:
setUserID in interface FTPSimpleClientI
Parameters:
id - User-ID.
Since:
1.1, 2006-04-14
See Also:
getUserID()

getPassword

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

Specified by:
getPassword in interface FTPSimpleClientI
Returns:
User password.
Since:
1.1, 2006-04-14
See Also:
setPassword()

setPassword

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

Specified by:
setPassword in interface FTPSimpleClientI
Parameters:
pwd - User password.
Since:
1.1, 2006-04-14
See Also:
getPassword()

setPassive

public 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. (By default, the client operates in passive mode.)

Specified by:
setPassive in interface FTPSimpleClientI
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-04-14

connect

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

Specified by:
connect in interface FTPSimpleClientI
Throws:
java.io.IOException - Thrown if unable to connect to the remote FTP system.
Since:
1.1, 2006-04-14
See Also:
disconnect()

disconnect

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

Specified by:
disconnect in interface FTPSimpleClientI
Since:
1.1, 2006-04-14
See Also:
connect()

isConnected

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

Specified by:
isConnected in interface FTPSimpleClientI
Returns:
True if this client has connected to a remote FTP system, otherwise false.
Since:
1.1, 2006-04-14
See Also:
connect(), disconnect()

login

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

Specified by:
login in interface FTPSimpleClientI
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-04-14
See Also:
connect(), setUserID(), setPassword()

login

public abstract void login(java.lang.String user,
                           java.lang.String pwd)
                    throws java.io.IOException
Log on to the remote FTP system.

Specified by:
login in interface FTPClientI
Parameters:
user - FTP user-ID for the remote system.
pwd - User password. This can be empty ("").
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-04-14
See Also:
login(), connect()

isLoggedIn

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

Specified by:
isLoggedIn in interface FTPSimpleClientI
Returns:
True if this client has connected and a user if logged into a remote FTP system, otherwise false.
Since:
1.1, 2006-04-14
See Also:
login()

setTextMode

public boolean setTextMode(boolean flag)
Set the transfer mode to text (ASCII) or binary. In text (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).

Specified by:
setTextMode in interface FTPSimpleClientI
Parameters:
flag - If true, the transfer mode is set to text (ASCII), otherwise it is set to binary.
Returns:
The previous mode setting.
Since:
1.9, 2007-07-26

ping

public abstract void ping()
                   throws java.io.IOException
Pings the remote FTP system. This sends a "NOOP" FTP command to the remote system and receives its reply.

Specified by:
ping in interface FTPClientI
Throws:
java.io.IOException - Thrown if an error occurs, e.g., the FTP connection is broken.
Since:
1.1, 2006-04-14

getSystemInfo

public abstract void getSystemInfo(java.io.OutputStream out)
                            throws java.io.IOException
Retrieve the identity information of the remote FTP system.

Specified by:
getSystemInfo in interface FTPClientI
Parameters:
out - Output stream to which the identification information is to be written.
Throws:
java.io.IOException - Thrown if an I/O error occurs.
Since:
API 2.0, 1.13, 2010-07-12

getStatus

public abstract void getStatus(java.io.OutputStream out)
                        throws java.io.IOException
Retrieve the current status of the remote FTP system.

Specified by:
getStatus in interface FTPClientI
Parameters:
out - Output stream to which the status is to be written.
Throws:
java.io.IOException - Thrown if an I/O error occurs.
Since:
API 2.0, 1.13, 2010-07-12

getHelp

public abstract void getHelp(java.io.OutputStream out)
                      throws java.io.IOException
Get (receive) a help listing of supported FTP commands from the remote FTP system.

Specified by:
getHelp in interface FTPClientI
Parameters:
out - Output stream to which the help listing is to be written.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
API 2.0, 1.13, 2010-07-12

setRemoteDir

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

Specified by:
setRemoteDir in interface FTPSimpleClientI
Parameters:
dir - Remote directory name.
Returns:
The new current remote directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-04-14
See Also:
setRemoteDirUp(), getRemoteDir(), setLocalDir()

setRemoteDirUp

public abstract 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.

Specified by:
setRemoteDirUp in interface FTPSimpleClientI
Returns:
The new current remote directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-04-14
See Also:
getRemoteDir(), setRemoteDir(), setLocalDir()

getRemoteDir

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

Specified by:
getRemoteDir in interface FTPSimpleClientI
Returns:
Remote directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-04-14
See Also:
setRemoteDir(), setRemoteDirUp(), getLocalDir()

setLocalDir

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

Specified by:
setLocalDir in interface FTPSimpleClientI
Parameters:
dir - Local directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-04-14
See Also:
getLocalDir(), setRemoteDir(), setRemoteDirUp()

getLocalDir

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

Specified by:
getLocalDir in interface FTPSimpleClientI
Returns:
The current local directory name.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-04-14
See Also:
setLocalDir(), getRemoteDir()

getFile

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

Specified by:
getFile in interface FTPClientI
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, 2006-04-14
See Also:
getFile(), getFile(), putFile()

getFile

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

Specified by:
getFile in interface FTPSimpleClientI
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, 2006-04-14
See Also:
getFile(), getFile(), putFile()

getFile

public abstract 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.

Specified by:
getFile in interface FTPSimpleClientI
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-14
See Also:
getFile(), getFile(), putFile()

putFile

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

Specified by:
putFile in interface FTPClientI
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, 2006-04-14
See Also:
putFile(), putFile(), getFile()

putFile

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

Specified by:
putFile in interface FTPSimpleClientI
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, 2006-04-14
See Also:
putFile(), putFile(), getFile()

putFile

public abstract 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.

Specified by:
putFile in interface FTPSimpleClientI
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-14
See Also:
putFile(), putFile(), getFile()

appendFile

public void appendFile(java.lang.String 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.

Specified by:
appendFile in interface FTPClientI
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.8, 2007-07-21
See Also:
appendFile(), appendFile(), getFile()

appendFile

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

Specified by:
appendFile in interface FTPSimpleClientI
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.8, 2007-07-21
See Also:
appendFile(), appendFile(), getFile()

appendFile

public abstract 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.

Specified by:
appendFile in interface FTPSimpleClientI
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.8, 2007-07-21
See Also:
appendFile(), appendFile(), getFile()

getDirectoryList

public void getDirectoryList(java.lang.String path,
                             java.io.OutputStream out)
                      throws java.io.IOException
Get (receive) a directory listing from the remote FTP system.

Specified by:
getDirectoryList in interface FTPClientI
Parameters:
path - The remote directory or file name to list. If this is empty (""), the current remote working directory is assumed.
out - Output stream to which the directory listing is to be written.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
API 2.0, 1.13, 2010-07-12

getDirectoryList

public abstract void getDirectoryList(java.lang.String path,
                                      int max,
                                      java.io.OutputStream out)
                               throws java.io.IOException
Get (receive) a directory listing from the remote FTP system.

Specified by:
getDirectoryList in interface FTPClientI
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 (output lines) to list. A value of zero (0) specifies that there is no maximum.
out - Output stream to which the directory listing is to be written.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
API 2.0, 1.13, 2010-07-12

getDirectoryNames

public void getDirectoryNames(java.lang.String path,
                              java.io.OutputStream out)
                       throws java.io.IOException
Get (receive) a list of filenames in a directory on the remote FTP system.

Specified by:
getDirectoryNames in interface FTPClientI
Parameters:
path - The remote directory or file name to list. If this is empty (""), the current remote working directory is assumed.
out - Output stream to which the directory listing is to be written.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
API 2.0, 1.13, 2010-07-12

getDirectoryNames

public abstract void getDirectoryNames(java.lang.String path,
                                       int max,
                                       java.io.OutputStream out)
                                throws java.io.IOException
Get (receive) a list of filenames in a directory on the remote FTP system.

Specified by:
getDirectoryNames in interface FTPClientI
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 get. A value of zero (0) specifies that there is no maximum.
out - Output stream to which the directory listing is to be written.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
API 2.0, 1.13, 2010-07-12

getDirectoryNames

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

Parameters:
path - The remote directory or file name to list. If this is empty (""), the current remote working directory is assumed.
Returns:
A vector of Strings containing the filenames in the remote directory.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.1, 2006-04-14

getDirectoryNames

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

Specified by:
getDirectoryNames in interface FTPSimpleClientI
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. Note that this may contain zero entries.
Throws:
java.io.IOException - Thrown if an error occurs.
Since:
1.4, 2007-02-28

rename

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

Specified by:
rename in interface FTPSimpleClientI
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-04-14

removeFile

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

Specified by:
removeFile in interface FTPSimpleClientI
Parameters:
file - Name of the file to delete. If this specifies a relative file name, 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-04-14

createDirectory

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

Specified by:
createDirectory in interface FTPSimpleClientI
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-04-14

removeDirectory

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

Specified by:
removeDirectory in interface FTPSimpleClientI
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-04-14

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalization.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable
Since:
1.1, 2006-04-14