    View Javadoc
    1   package org.apache.commons.net.ftp;
    2
    3   /* ====================================================================
    4    * The Apache Software License, Version 1.1
    5    *
    6    * Copyright (c) 2001 The Apache Software Foundation.  All rights
    7    * reserved.
    8    *
    9    * Redistribution and use in source and binary forms, with or without
    10   * modification, are permitted provided that the following conditions
    11   * are met:
    12   *
    13   * 1. Redistributions of source code must retain the above copyright
    14   *    notice, this list of conditions and the following disclaimer.
    15   *
    16   * 2. Redistributions in binary form must reproduce the above copyright
    17   *    notice, this list of conditions and the following disclaimer in
    18   *    the documentation and/or other materials provided with the
    19   *    distribution.
    20   *
    21   * 3. The end-user documentation included with the redistribution,
    22   *    if any, must include the following acknowledgment:
    23   *       "This product includes software developed by the
    24   *        Apache Software Foundation (http://www.apache.org/)."
    25   *    Alternately, this acknowledgment may appear in the software itself,
    26   *    if and wherever such third-party acknowledgments normally appear.
    27   *
    28   * 4. The names "Apache" and "Apache Software Foundation" and
    29   *    "Apache Commons" must not be used to endorse or promote products
    30   *    derived from this software without prior written permission. For
    31   *    written permission, please contact apache@apache.org.
    32   *
    33   * 5. Products derived from this software may not be called "Apache",
    34   *    nor may "Apache" appear in their name, without
    35   *    prior written permission of the Apache Software Foundation.
    36   *
    37   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    38   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    39   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    40   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    41   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    42   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    43   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    44   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    45   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    46   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    47   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    48   * SUCH DAMAGE.
    49   * ====================================================================
    50   *
    51   * This software consists of voluntary contributions made by many
    52   * individuals on behalf of the Apache Software Foundation.  For more
    53   * information on the Apache Software Foundation, please see
    54   * <http://www.apache.org/>;.
    55   */
    56
    57  import java.io.BufferedReader;
    58  import java.io.BufferedWriter;
    59  import java.io.IOException;
    60  import java.io.InputStreamReader;
    61  import java.io.OutputStreamWriter;
    62  import java.net.InetAddress;
    63  import java.util.Enumeration;
    64  import java.util.Vector;
    65  import org.apache.commons.net.MalformedServerReplyException;
    66  import org.apache.commons.net.ProtocolCommandListener;
    67  import org.apache.commons.net.ProtocolCommandSupport;
    68  import org.apache.commons.net.SocketClient;
    69  import org.apache.commons.net.telnet.TelnetClient;
    70
    71  /****
    72   * FTP provides the basic the functionality necessary to implement your
    73   * own FTP client.  It extends org.apache.commons.net.TelnetClient
    74   * simply because it saves the writing of extra code to handle the FTP
    75   * control connection which always remains open during an FTP session and
    76   * uses the Telnet protocol.  Aggregation would require writing new
    77   * wrapper methods and wouldn't leverage the functionality already
    78   * present in org.apache.commons.net.SocketClient.
    79   * <p>
    80   * To derive the full benefits of the FTP class requires some knowledge
    81   * of the FTP protocol defined in RFC 959.  However, there is no reason
    82   * why you should have to use the FTP class.  The
    83   * <a href="org.apache.commons.net.ftp.FTPClient.html"> FTPClient </a> class,
    84   * derived from FTP,
    85   * implements all the functionality required of an FTP client.  The
    86   * FTP class is made public to provide access to various FTP constants
    87   * and to make it easier for adventurous programmers (or those with
    88   * special needs) to interact with the FTP protocol and implement their
    89   * own clients.  A set of methods with names corresponding to the FTP
    90   * command names are provided to facilitate this interaction.
    91   * <p>
    92   * You should keep in mind that the FTP server may choose to prematurely
    93   * close a connection if the client has been idle for longer than a
    94   * given time period (usually 900 seconds).  The FTP class will detect a
    95   * premature FTP server connection closing when it receives a
    96   * <a href="org.apache.commons.net.ftp.FTPReply.html#SERVICE_NOT_AVAILABLE">
    97   * FTPReply.SERVICE_NOT_AVAILABLE </a> response to a command.
    98   * When that occurs, the FTP class method encountering that reply will throw
    99   * an <a href="org.apache.commons.net.ftp.FTPConnectionClosedException.html">
    100  * FTPConnectionClosedException </a>.  <code>FTPConectionClosedException</code>
    101  * is a subclass of <code> IOException </code> and therefore need not be
    102  * caught separately, but if you are going to catch it separately, its
    103  * catch block must appear before the more general <code> IOException </code>
    104  * catch block.  When you encounter an
    105  * <a href="org.apache.commons.net.ftp.FTPConnectionClosedException.html">
    106  * FTPConnectionClosedException </a>, you must disconnect the connection with
    107  * <a href="#disconnect"> disconnect() </a> to properly clean up the
    108  * system resources used by FTP.  Before disconnecting, you may check the
    109  * last reply code and text with
    110  * <a href="#getReplyCode"> getReplyCode </a>,
    111  * <a href="#getReplyString"> getReplyString </a>,
    112  * and <a href="#getReplyStrings"> getReplyStrings</a>.
    113  * You may avoid server disconnections while the client is idle by
    114  * periodicaly sending NOOP commands to the server.
    115  * <p>
    116  * Rather than list it separately for each method, we mention here that
    117  * every method communicating with the server and throwing an IOException
    118  * can also throw a
    119  * <a href="org.apache.commons.net.MalformedServerReplyException.html">
    120  * MalformedServerReplyException </a>, which is a subclass
    121  * of IOException.  A MalformedServerReplyException will be thrown when
    122  * the reply received from the server deviates enough from the protocol
    123  * specification that it cannot be interpreted in a useful manner despite
    124  * attempts to be as lenient as possible.
    125  * <p>
    126  * <p>
    127  * @author Daniel F. Savarese
    128  * @see FTPClient
    129  * @see FTPConnectionClosedException
    130  * @see org.apache.commons.net.MalformedServerReplyException
    131  ***/
    132
    133 public class FTP extends TelnetClient
    134 {
    135     /**** The default FTP data port (20). ***/
    136     public static final int DEFAULT_DATA_PORT = 20;
    137     /**** The default FTP control port (21). ***/
    138     public static final int DEFAULT_PORT = 21;
    139
    140     /****
    141      * A constant used to indicate the file(s) being transfered should
    142      * be treated as ASCII.  This is the default file type.  All constants
    143      * ending in <code>FILE_TYPE</code> are used to indicate file types.
    144      ***/
    145     public static final int ASCII_FILE_TYPE = 0;
    146
    147     /****
    148      * A constant used to indicate the file(s) being transfered should
    149      * be treated as EBCDIC.  Note however that there are several different
    150      * EBCDIC formats.  All constants ending in <code>FILE_TYPE</code>
    151      * are used to indicate file types.
    152      ***/
    153     public static final int EBCDIC_FILE_TYPE = 1;
    154
    155     /****
    156      * A constant used to indicate the file(s) being transfered should
    157      * be treated as a binary image, i.e., no translations should be
    158      * performed.  All constants ending in <code>FILE_TYPE</code> are used to
    159      * indicate file types.
    160      ***/
    161     public static final int IMAGE_FILE_TYPE = 2;
    162
    163     /****
    164      * A constant used to indicate the file(s) being transfered should
    165      * be treated as a binary image, i.e., no translations should be
    166      * performed.  All constants ending in <code>FILE_TYPE</code> are used to
    167      * indicate file types.
    168      ***/
    169     public static final int BINARY_FILE_TYPE = 2;
    170
    171     /****
    172      * A constant used to indicate the file(s) being transfered should
    173      * be treated as a local type.  All constants ending in
    174      * <code>FILE_TYPE</code> are used to indicate file types.
    175      ***/
    176     public static final int LOCAL_FILE_TYPE = 3;
    177
    178     /****
    179      * A constant used for text files to indicate a non-print text format.
    180      * This is the default format.
    181      * All constants ending in <code>TEXT_FORMAT</code> are used to indicate
    182      * text formatting for text transfers (both ASCII and EBCDIC).
    183      ***/
    184     public static final int NON_PRINT_TEXT_FORMAT = 4;
    185
    186     /****
    187      * A constant used to indicate a text file contains format vertical format
    188      * control characters.
    189      * All constants ending in <code>TEXT_FORMAT</code> are used to indicate
    190      * text formatting for text transfers (both ASCII and EBCDIC).
    191      ***/
    192     public static final int TELNET_TEXT_FORMAT = 5;
    193
    194     /****
    195      * A constant used to indicate a text file contains ASA vertical format
    196      * control characters.
    197      * All constants ending in <code>TEXT_FORMAT</code> are used to indicate
    198      * text formatting for text transfers (both ASCII and EBCDIC).
    199      ***/
    200     public static final int CARRIAGE_CONTROL_TEXT_FORMAT = 6;
    201
    202     /****
    203      * A constant used to indicate a file is to be treated as a continuous
    204      * sequence of bytes.  This is the default structure.  All constants ending
    205      * in <code>_STRUCTURE</code> are used to indicate file structure for
    206      * file transfers.
    207      ***/
    208     public static final int FILE_STRUCTURE = 7;
    209
    210     /****
    211      * A constant used to indicate a file is to be treated as a sequence
    212      * of records.  All constants ending in <code>_STRUCTURE</code>
    213      * are used to indicate file structure for file transfers.
    214      ***/
    215     public static final int RECORD_STRUCTURE = 8;
    216
    217     /****
    218      * A constant used to indicate a file is to be treated as a set of
    219      * independent indexed pages.  All constants ending in
    220      * <code>_STRUCTURE</code> are used to indicate file structure for file
    221      * transfers.
    222      ***/
    223     public static final int PAGE_STRUCTURE = 9;
    224
    225     /****
    226      * A constant used to indicate a file is to be transfered as a stream
    227      * of bytes.  This is the default transfer mode.  All constants ending
    228      * in <code>TRANSFER_MODE</code> are used to indicate file transfer
    229      * modes.
    230      ***/
    231     public static final int STREAM_TRANSFER_MODE = 10;
    232
    233     /****
    234      * A constant used to indicate a file is to be transfered as a series
    235      * of blocks.  All constants ending in <code>TRANSFER_MODE</code> are used
    236      * to indicate file transfer modes.
    237      ***/
    238     public static final int BLOCK_TRANSFER_MODE = 11;
    239
    240     /****
    241      * A constant used to indicate a file is to be transfered as FTP
    242      * compressed data.  All constants ending in <code>TRANSFER_MODE</code>
    243      * are used to indicate file transfer modes.
    244      ***/
    245     public static final int COMPRESSED_TRANSFER_MODE = 12;
    246
    247     private static final String __modes = "ABILNTCFRPSBC";
    248
    249     private StringBuffer __commandBuffer;
    250
    251     BufferedReader _controlInput;
    252     BufferedWriter _controlOutput;
    253     int _replyCode;
    254     Vector _replyLines;
    255     boolean _newReplyString;
    256     String _replyString;
    257
    258     /****
    259      * A ProtocolCommandSupport object used to manage the registering of
    260      * ProtocolCommandListeners and te firing of ProtocolCommandEvents.
    261      ***/
    262     protected ProtocolCommandSupport _commandSupport_;
    263
    264     /****
    265      * The default FTP constructor.  Sets the default port to
    266      * <code>DEFAULT_PORT</code> and initializes internal data structures
    267      * for saving FTP reply information.
    268      ***/
    269     public FTP()
    270     {
    271         setDefaultPort(DEFAULT_PORT);
    272         __commandBuffer = new StringBuffer();
    273         _replyLines = new Vector();
    274         _newReplyString = false;
    275         _replyString = null;
    276         _commandSupport_ = new ProtocolCommandSupport(this);
    277     }
    278
    279     private void __getReply() throws IOException
    280     {
    281         int length;
    282         String line, code;
    283
    284         _newReplyString = true;
    285         _replyLines.setSize(0);
    286
    287         line = _controlInput.readLine();
    288
    289         if (line == null)
    290             throw new FTPConnectionClosedException(
    291                 "Connection closed without indication.");
    292
    293         // In case we run into an anomaly we don't want fatal index exceptions
    294         // to be thrown.
    295         length = line.length();
    296         if (length < 3)
    297             throw new MalformedServerReplyException(
    298                 "Truncated server reply: " + line);
    299
    300         try
    301         {
    302             _replyCode = Integer.parseInt(code = line.substring(0, 3));
    303         }
    304         catch (NumberFormatException e)
    305         {
    306             throw new MalformedServerReplyException(
    307                 "Could not parse response code.\nServer Reply: " + line);
    308         }
    309
    310         _replyLines.addElement(line);
    311
    312         // Get extra lines if message continues.
    313         if (length > 3 && line.charAt(3) == '-')
    314         {
    315             do
    316             {
    317                 line = _controlInput.readLine();
    318
    319                 if (line == null)
    320                     throw new FTPConnectionClosedException(
    321                         "Connection closed without indication.");
    322
    323                 _replyLines.addElement(line);
    324
    325                 // The length() check handles problems that could arise from readLine()
    326                 // returning too soon after encountering a naked CR or some other
    327                 // anomaly.
    328             }
    329             while (!(line.length() >= 4 && line.charAt(3) != '-' &&
    330                      Character.isDigit(line.charAt(0))));
    331             // This is too strong a condition because of non-conforming ftp
    332             // servers like ftp.funet.fi which sent 226 as the last line of a
    333             // 426 multi-line reply in response to ls /.  We relax the condition to
    334             // test that the line starts with a digit rather than starting with
    335             // the code.
    336             // line.startsWith(code)));
    337         }
    338
    339         if (_commandSupport_.getListenerCount() > 0)
    340             _commandSupport_.fireReplyReceived(_replyCode, getReplyString());
    341
    342         if (_replyCode == FTPReply.SERVICE_NOT_AVAILABLE)
    343             throw new FTPConnectionClosedException(
    344                 "FTP response 421 received.  Server closed connection.");
    345     }
    346
    347     // initiates control connections and gets initial reply
    348     protected void _connectAction_() throws IOException
    349     {
    350         super._connectAction_();
    351         _controlInput =
    352             new BufferedReader(new InputStreamReader(getInputStream()));
    353         _controlOutput =
    354             new BufferedWriter(new OutputStreamWriter(getOutputStream()));
    355         __getReply();
    356         // If we received code 120, we have to fetch completion reply.
    357         if (FTPReply.isPositivePreliminary(_replyCode))
    358             __getReply();
    359     }
    360
    361
    362     /****
    363      * Adds a ProtocolCommandListener.  Delegates this task to
    364      * <a href="#_commandSupport_"> _commandSupport_ </a>.
    365      * <p>
    366      * @param listener  The ProtocolCommandListener to add.
    367      ***/
    368     public void addProtocolCommandListener(ProtocolCommandListener listener)
    369     {
    370         _commandSupport_.addProtocolCommandListener(listener);
    371     }
    372
    373     /****
    374      * Removes a ProtocolCommandListener.  Delegates this task to
    375      * <a href="#_commandSupport_"> _commandSupport_ </a>.
    376      * <p>
    377      * @param listener  The ProtocolCommandListener to remove.
    378      ***/
    379     public void removeProtocolCommandistener(ProtocolCommandListener listener)
    380     {
    381         _commandSupport_.removeProtocolCommandListener(listener);
    382     }
    383
    384
    385     /****
    386      * Closes the control connection to the FTP server and sets to null
    387      * some internal data so that the memory may be reclaimed by the
    388      * garbage collector.  The reply text and code information from the
    389      * last command is voided so that the memory it used may be reclaimed.
    390      * <p>
    391      * @exception IOException If an error occurs while disconnecting.
    392      ***/
    393     public void disconnect() throws IOException
    394     {
    395         super.disconnect();
    396         _controlInput = null;
    397         _controlOutput = null;
    398         _replyLines.setSize(0);
    399         _newReplyString = false;
    400         _replyString = null;
    401     }
    402
    403
    404     /****
    405      * Sends an FTP command to the server, waits for a reply and returns the
    406      * numerical response code.  After invocation, for more detailed
    407      * information, the actual reply text can be accessed by calling
    408      * <a href="#getReplyString"> getReplyString </a> or
    409      * <a href="#getReplyStrings"> getReplyStrings </a>.
    410      * <p>
    411      * @param command  The text representation of the  FTP command to send.
    412      * @param args The arguments to the FTP command.  If this parameter is
    413      *             set to null, then the command is sent with no argument.
    414      * @return The integer value of the FTP reply code returned by the server
    415      *         in response to the command.
    416      * @exception FTPConnectionClosedException
    417      *      If the FTP server prematurely closes the connection as a result
    418      *      of the client being idle or some other reason causing the server
    419      *      to send FTP reply code 421.  This exception may be caught either
    420      *      as an IOException or independently as itself.
    421      * @exception IOException  If an I/O error occurs while either sending the
    422      *      command or receiving the server reply.
    423      ***/
    424     public int sendCommand(String command, String args) throws IOException
    425     {
    426         String message;
    427
    428         __commandBuffer.setLength(0);
    429         __commandBuffer.append(command);
    430
    431         if (args != null)
    432         {
    433             __commandBuffer.append(' ');
    434             __commandBuffer.append(args);
    435         }
    436         __commandBuffer.append(SocketClient.NETASCII_EOL);
    437
    438         _controlOutput.write(message = __commandBuffer.toString());
    439         _controlOutput.flush();
    440
    441         if (_commandSupport_.getListenerCount() > 0)
    442             _commandSupport_.fireCommandSent(command, message);
    443
    444         __getReply();
    445         return _replyCode;
    446     }
    447
    448
    449     /****
    450      * Sends an FTP command to the server, waits for a reply and returns the
    451      * numerical response code.  After invocation, for more detailed
    452      * information, the actual reply text can be accessed by calling
    453      * <a href="#getReplyString"> getReplyString </a> or
    454      * <a href="#getReplyStrings"> getReplyStrings </a>.
    455      * <p>
    456      * @param command  The FTPCommand constant corresponding to the FTP command
    457      *                 to send.
    458      * @param args The arguments to the FTP command.  If this parameter is
    459      *             set to null, then the command is sent with no argument.
    460      * @return The integer value of the FTP reply code returned by the server
    461      *         in response to the command.
    462      * @exception FTPConnectionClosedException
    463      *      If the FTP server prematurely closes the connection as a result
    464      *      of the client being idle or some other reason causing the server
    465      *      to send FTP reply code 421.  This exception may be caught either
    466      *      as an IOException or independently as itself.
    467      * @exception IOException  If an I/O error occurs while either sending the
    468      *      command or receiving the server reply.
    469      ***/
    470     public int sendCommand(int command, String args) throws IOException
    471     {
    472         return sendCommand(FTPCommand._commands[command], args);
    473     }
    474
    475
    476     /****
    477      * Sends an FTP command with no arguments to the server, waits for a
    478      * reply and returns the numerical response code.  After invocation, for
    479      * more detailed information, the actual reply text can be accessed by
    480      * calling <a href="#getReplyString"> getReplyString </a> or
    481      * <a href="#getReplyStrings"> getReplyStrings </a>.
    482      * <p>
    483      * @param command  The text representation of the  FTP command to send.
    484      * @return The integer value of the FTP reply code returned by the server
    485      *         in response to the command.
    486      * @exception FTPConnectionClosedException
    487      *      If the FTP server prematurely closes the connection as a result
    488      *      of the client being idle or some other reason causing the server
    489      *      to send FTP reply code 421.  This exception may be caught either
    490      *      as an IOException or independently as itself.
    491      * @exception IOException  If an I/O error occurs while either sending the
    492      *      command or receiving the server reply.
    493      ***/
    494     public int sendCommand(String command) throws IOException
    495     {
    496         return sendCommand(command, null);
    497     }
    498
    499
    500     /****
    501      * Sends an FTP command with no arguments to the server, waits for a
    502      * reply and returns the numerical response code.  After invocation, for
    503      * more detailed information, the actual reply text can be accessed by
    504      * calling <a href="#getReplyString"> getReplyString </a> or
    505      * <a href="#getReplyStrings"> getReplyStrings </a>.
    506      * <p>
    507      * @param command  The FTPCommand constant corresponding to the FTP command
    508      *                 to send.
    509      * @return The integer value of the FTP reply code returned by the server
    510      *         in response to the command.
    511      * @exception FTPConnectionClosedException
    512      *      If the FTP server prematurely closes the connection as a result
    513      *      of the client being idle or some other reason causing the server
    514      *      to send FTP reply code 421.  This exception may be caught either
    515      *      as an IOException or independently as itself.
    516      * @exception IOException  If an I/O error occurs while either sending the
    517      *      command or receiving the server reply.
    518      ***/
    519     public int sendCommand(int command) throws IOException
    520     {
    521         return sendCommand(command, null);
    522     }
    523
    524
    525     /****
    526      * Returns the integer value of the reply code of the last FTP reply.
    527      * You will usually only use this method after you connect to the
    528      * FTP server to check that the connection was successful since
    529      * <code> connect </code> is of type void.
    530      * <p>
    531      * @return The integer value of the reply code of the last FTP reply.
    532      ***/
    533     public int getReplyCode()
    534     {
    535         return _replyCode;
    536     }
    537
    538     /****
    539      * Fetches a reply from the FTP server and returns the integer reply
    540      * code.  After calling this method, the actual reply text can be accessed
    541      * from either  calling <a href="#getReplyString"> getReplyString </a> or
    542      * <a href="#getReplyStrings"> getReplyStrings </a>.  Only use this
    543      * method if you are implementing your own FTP client or if you need to
    544      * fetch a secondary response from the FTP server.
    545      * <p>
    546      * @return The integer value of the reply code of the fetched FTP reply.
    547      * @exception FTPConnectionClosedException
    548      *      If the FTP server prematurely closes the connection as a result
    549      *      of the client being idle or some other reason causing the server
    550      *      to send FTP reply code 421.  This exception may be caught either
    551      *      as an IOException or independently as itself.
    552      * @exception IOException  If an I/O error occurs while receiving the
    553      *                         server reply.
    554      ***/
    555     public int getReply() throws IOException
    556     {
    557         __getReply();
    558         return _replyCode;
    559     }
    560
    561
    562     /****
    563      * Returns the lines of text from the last FTP server response as an array
    564      * of strings, one entry per line.  The end of line markers of each are
    565      * stripped from each line.
    566      * <p>
    567      * @return The lines of text from the last FTP response as an array.
    568      ***/
    569     public String[] getReplyStrings()
    570     {
    571         String[] lines;
    572         lines = new String[_replyLines.size()];
    573         _replyLines.copyInto(lines);
    574         return lines;
    575     }
    576
    577     /****
    578      * Returns the entire text of the last FTP server response exactly
    579      * as it was received, including all end of line markers in NETASCII
    580      * format.
    581      * <p>
    582      * @return The entire text from the last FTP response as a String.
    583      ***/
    584     public String getReplyString()
    585     {
    586         Enumeration enum;
    587         StringBuffer buffer;
    588
    589         if (!_newReplyString)
    590             return _replyString;
    591
    592         buffer = new StringBuffer(256);
    593         enum = _replyLines.elements();
    594         while (enum.hasMoreElements())
    595         {
    596             buffer.append((String)enum.nextElement());
    597             buffer.append(SocketClient.NETASCII_EOL);
    598         }
    599
    600         _newReplyString = false;
    601
    602         return (_replyString = buffer.toString());
    603     }
    604
    605
    606     /****
    607      * A convenience method to send the FTP USER command to the server,
    608      * receive the reply, and return the reply code.
    609      * <p>
    610      * @param username  The username to login under.
    611      * @return The reply code received from the server.
    612      * @exception FTPConnectionClosedException
    613      *      If the FTP server prematurely closes the connection as a result
    614      *      of the client being idle or some other reason causing the server
    615      *      to send FTP reply code 421.  This exception may be caught either
    616      *      as an IOException or independently as itself.
    617      * @exception IOException  If an I/O error occurs while either sending the
    618      *      command or receiving the server reply.
    619      ***/
    620     public int user(String username) throws IOException
    621     {
    622         return sendCommand(FTPCommand.USER, username);
    623     }
    624
    625     /****
    626      * A convenience method to send the FTP PASS command to the server,
    627      * receive the reply, and return the reply code.
    628      * <p>
    629      * @param pass  The plain text password of the username being logged into.
    630      * @return The reply code received from the server.
    631      * @exception FTPConnectionClosedException
    632      *      If the FTP server prematurely closes the connection as a result
    633      *      of the client being idle or some other reason causing the server
    634      *      to send FTP reply code 421.  This exception may be caught either
    635      *      as an IOException or independently as itself.
    636      * @exception IOException  If an I/O error occurs while either sending the
    637      *      command or receiving the server reply.
    638      ***/
    639     public int pass(String password) throws IOException
    640     {
    641         return sendCommand(FTPCommand.PASS, password);
    642     }
    643
    644     /****
    645      * A convenience method to send the FTP ACCT command to the server,
    646      * receive the reply, and return the reply code.
    647      * <p>
    648      * @param account  The account name to access.
    649      * @return The reply code received from the server.
    650      * @exception FTPConnectionClosedException
    651      *      If the FTP server prematurely closes the connection as a result
    652      *      of the client being idle or some other reason causing the server
    653      *      to send FTP reply code 421.  This exception may be caught either
    654      *      as an IOException or independently as itself.
    655      * @exception IOException  If an I/O error occurs while either sending the
    656      *      command or receiving the server reply.
    657      ***/
    658     public int acct(String account) throws IOException
    659     {
    660         return sendCommand(FTPCommand.ACCT, account);
    661     }
    662
    663
    664     /****
    665      * A convenience method to send the FTP ABOR command to the server,
    666      * receive the reply, and return the reply code.
    667      * <p>
    668      * @return The reply code received from the server.
    669      * @exception FTPConnectionClosedException
    670      *      If the FTP server prematurely closes the connection as a result
    671      *      of the client being idle or some other reason causing the server
    672      *      to send FTP reply code 421.  This exception may be caught either
    673      *      as an IOException or independently as itself.
    674      * @exception IOException  If an I/O error occurs while either sending the
    675      *      command or receiving the server reply.
    676      ***/
    677     public int abor() throws IOException
    678     {
    679         return sendCommand(FTPCommand.ABOR);
    680     }
    681
    682     /****
    683      * A convenience method to send the FTP CWD command to the server,
    684      * receive the reply, and return the reply code.
    685      * <p>
    686      * @param directory The new working directory.
    687      * @return The reply code received from the server.
    688      * @exception FTPConnectionClosedException
    689      *      If the FTP server prematurely closes the connection as a result
    690      *      of the client being idle or some other reason causing the server
    691      *      to send FTP reply code 421.  This exception may be caught either
    692      *      as an IOException or independently as itself.
    693      * @exception IOException  If an I/O error occurs while either sending the
    694      *      command or receiving the server reply.
    695      ***/
    696     public int cwd(String directory) throws IOException
    697     {
    698         return sendCommand(FTPCommand.CWD, directory);
    699     }
    700
    701     /****
    702      * A convenience method to send the FTP CDUP command to the server,
    703      * receive the reply, and return the reply code.
    704      * <p>
    705      * @return The reply code received from the server.
    706      * @exception FTPConnectionClosedException
    707      *      If the FTP server prematurely closes the connection as a result
    708      *      of the client being idle or some other reason causing the server
    709      *      to send FTP reply code 421.  This exception may be caught either
    710      *      as an IOException or independently as itself.
    711      * @exception IOException  If an I/O error occurs while either sending the
    712      *      command or receiving the server reply.
    713      ***/
    714     public int cdup() throws IOException
    715     {
    716         return sendCommand(FTPCommand.CDUP);
    717     }
    718
    719     /****
    720      * A convenience method to send the FTP QUIT command to the server,
    721      * receive the reply, and return the reply code.
    722      * <p>
    723      * @return The reply code received from the server.
    724      * @exception FTPConnectionClosedException
    725      *      If the FTP server prematurely closes the connection as a result
    726      *      of the client being idle or some other reason causing the server
    727      *      to send FTP reply code 421.  This exception may be caught either
    728      *      as an IOException or independently as itself.
    729      * @exception IOException  If an I/O error occurs while either sending the
    730      *      command or receiving the server reply.
    731      ***/
    732     public int quit() throws IOException
    733     {
    734         return sendCommand(FTPCommand.QUIT);
    735     }
    736
    737     /****
    738      * A convenience method to send the FTP REIN command to the server,
    739      * receive the reply, and return the reply code.
    740      * <p>
    741      * @return The reply code received from the server.
    742      * @exception FTPConnectionClosedException
    743      *      If the FTP server prematurely closes the connection as a result
    744      *      of the client being idle or some other reason causing the server
    745      *      to send FTP reply code 421.  This exception may be caught either
    746      *      as an IOException or independently as itself.
    747      * @exception IOException  If an I/O error occurs while either sending the
    748      *      command or receiving the server reply.
    749      ***/
    750     public int rein() throws IOException
    751     {
    752         return sendCommand(FTPCommand.REIN);
    753     }
    754
    755     /****
    756      * A convenience method to send the FTP SMNT command to the server,
    757      * receive the reply, and return the reply code.
    758      * <p>
    759      * @param dir  The directory name.
    760      * @return The reply code received from the server.
    761      * @exception FTPConnectionClosedException
    762      *      If the FTP server prematurely closes the connection as a result
    763      *      of the client being idle or some other reason causing the server
    764      *      to send FTP reply code 421.  This exception may be caught either
    765      *      as an IOException or independently as itself.
    766      * @exception IOException  If an I/O error occurs while either sending the
    767      *      command or receiving the server reply.
    768      ***/
    769     public int smnt(String dir) throws IOException
    770     {
    771         return sendCommand(FTPCommand.SMNT);
    772     }
    773
    774     /****
    775      * A convenience method to send the FTP PORT command to the server,
    776      * receive the reply, and return the reply code.
    777      * <p>
    778      * @param host  The host owning the port.
    779      * @param port  The new port.
    780      * @return The reply code received from the server.
    781      * @exception FTPConnectionClosedException
    782      *      If the FTP server prematurely closes the connection as a result
    783      *      of the client being idle or some other reason causing the server
    784      *      to send FTP reply code 421.  This exception may be caught either
    785      *      as an IOException or independently as itself.
    786      * @exception IOException  If an I/O error occurs while either sending the
    787      *      command or receiving the server reply.
    788      ***/
    789     public int port(InetAddress host, int port) throws IOException
    790     {
    791         int num;
    792         StringBuffer info = new StringBuffer(24);
    793
    794         info.append(host.getHostAddress().replace('.', ','));
    795         num = port >>> 8;
    796         info.append(',');
    797         info.append(num);
    798         info.append(',');
    799         num = port & 0xff;
    800         info.append(num);
    801
    802         return sendCommand(FTPCommand.PORT, info.toString());
    803     }
    804
    805     /****
    806      * A convenience method to send the FTP PASV command to the server,
    807      * receive the reply, and return the reply code.  Remember, it's up
    808      * to you to interpret the reply string containing the host/port
    809      * information.
    810      * <p>
    811      * @return The reply code received from the server.
    812      * @exception FTPConnectionClosedException
    813      *      If the FTP server prematurely closes the connection as a result
    814      *      of the client being idle or some other reason causing the server
    815      *      to send FTP reply code 421.  This exception may be caught either
    816      *      as an IOException or independently as itself.
    817      * @exception IOException  If an I/O error occurs while either sending the
    818      *      command or receiving the server reply.
    819      ***/
    820     public int pasv() throws IOException
    821     {
    822         return sendCommand(FTPCommand.PASV);
    823     }
    824
    825     /****
    826      * A convenience method to send the FTP TYPE command for text files
    827      * to the server, receive the reply, and return the reply code.
    828      * <p>
    829      * @param type  The type of the file (one of the <code>FILE_TYPE</code>
    830      *              constants).
    831      * @param formatOrByteSize  The format of the file (one of the
    832      *              <code>_FORMAT</code> constants.  In the case of
    833      *              <code>LOCAL_FILE_TYPE</code>, the byte size.
    834      * @return The reply code received from the server.
    835      * @exception FTPConnectionClosedException
    836      *      If the FTP server prematurely closes the connection as a result
    837      *      of the client being idle or some other reason causing the server
    838      *      to send FTP reply code 421.  This exception may be caught either
    839      *      as an IOException or independently as itself.
    840      * @exception IOException  If an I/O error occurs while either sending the
    841      *      command or receiving the server reply.
    842      ***/
    843     public int type(int fileType, int formatOrByteSize) throws IOException
    844     {
    845         StringBuffer arg = new StringBuffer();
    846
    847         arg.append(__modes.charAt(fileType));
    848         arg.append(' ');
    849         if (fileType == LOCAL_FILE_TYPE)
    850             arg.append(formatOrByteSize);
    851         else
    852             arg.append(__modes.charAt(formatOrByteSize));
    853
    854         return sendCommand(FTPCommand.TYPE, arg.toString());
    855     }
    856
    857
    858     /****
    859      * A convenience method to send the FTP TYPE command to the server,
    860      * receive the reply, and return the reply code.
    861      * <p>
    862      * @param type  The type of the file (one of the <code>FILE_TYPE</code>
    863      *              constants).
    864      * @return The reply code received from the server.
    865      * @exception FTPConnectionClosedException
    866      *      If the FTP server prematurely closes the connection as a result
    867      *      of the client being idle or some other reason causing the server
    868      *      to send FTP reply code 421.  This exception may be caught either
    869      *      as an IOException or independently as itself.
    870      * @exception IOException  If an I/O error occurs while either sending the
    871      *      command or receiving the server reply.
    872      ***/
    873     public int type(int fileType) throws IOException
    874     {
    875         return sendCommand(FTPCommand.TYPE,
    876                            __modes.substring(fileType, fileType + 1));
    877     }
    878
    879     /****
    880      * A convenience method to send the FTP STRU command to the server,
    881      * receive the reply, and return the reply code.
    882      * <p>
    883      * @param structure  The structure of the file (one of the
    884      *         <code>_STRUCTURE</code> constants).
    885      * @return The reply code received from the server.
    886      * @exception FTPConnectionClosedException
    887      *      If the FTP server prematurely closes the connection as a result
    888      *      of the client being idle or some other reason causing the server
    889      *      to send FTP reply code 421.  This exception may be caught either
    890      *      as an IOException or independently as itself.
    891      * @exception IOException  If an I/O error occurs while either sending the
    892      *      command or receiving the server reply.
    893      ***/
    894     public int stru(int structure) throws IOException
    895     {
    896         return sendCommand(FTPCommand.STRU,
    897                            __modes.substring(structure, structure + 1));
    898     }
    899
    900     /****
    901      * A convenience method to send the FTP MODE command to the server,
    902      * receive the reply, and return the reply code.
    903      * <p>
    904      * @param mode  The transfer mode to use (one of the
    905      *         <code>TRANSFER_MODE</code> constants).
    906      * @return The reply code received from the server.
    907      * @exception FTPConnectionClosedException
    908      *      If the FTP server prematurely closes the connection as a result
    909      *      of the client being idle or some other reason causing the server
    910      *      to send FTP reply code 421.  This exception may be caught either
    911      *      as an IOException or independently as itself.
    912      * @exception IOException  If an I/O error occurs while either sending the
    913      *      command or receiving the server reply.
    914      ***/
    915     public int mode(int mode) throws IOException
    916     {
    917         return sendCommand(FTPCommand.MODE,
    918                            __modes.substring(mode, mode + 1));
    919     }
    920
    921     /****
    922      * A convenience method to send the FTP RETR command to the server,
    923      * receive the reply, and return the reply code.  Remember, it is up
    924      * to you to manage the data connection.  If you don't need this low
    925      * level of access, use <a href="org.apache.commons.net.ftp.FTPClient.html">
    926      * FTPClient</a>, which will handle all low level details for you.
    927      * <p>
    928      * @param pathname  The pathname of the file to retrieve.
    929      * @return The reply code received from the server.
    930      * @exception FTPConnectionClosedException
    931      *      If the FTP server prematurely closes the connection as a result
    932      *      of the client being idle or some other reason causing the server
    933      *      to send FTP reply code 421.  This exception may be caught either
    934      *      as an IOException or independently as itself.
    935      * @exception IOException  If an I/O error occurs while either sending the
    936      *      command or receiving the server reply.
    937      ***/
    938     public int retr(String pathname) throws IOException
    939     {
    940         return sendCommand(FTPCommand.RETR, pathname);
    941     }
    942
    943     /****
    944      * A convenience method to send the FTP STOR command to the server,
    945      * receive the reply, and return the reply code.  Remember, it is up
    946      * to you to manage the data connection.  If you don't need this low
    947      * level of access, use <a href="org.apache.commons.net.ftp.FTPClient.html">
    948      * FTPClient</a>, which will handle all low level details for you.
    949      * <p>
    950      * @param pathname  The pathname to use for the file when stored at
    951      *                  the remote end of the transfer.
    952      * @return The reply code received from the server.
    953      * @exception FTPConnectionClosedException
    954      *      If the FTP server prematurely closes the connection as a result
    955      *      of the client being idle or some other reason causing the server
    956      *      to send FTP reply code 421.  This exception may be caught either
    957      *      as an IOException or independently as itself.
    958      * @exception IOException  If an I/O error occurs while either sending the
    959      *      command or receiving the server reply.
    960      ***/
    961     public int stor(String pathname) throws IOException
    962     {
    963         return sendCommand(FTPCommand.STOR, pathname);
    964     }
    965
    966     /****
    967      * A convenience method to send the FTP STOU command to the server,
    968      * receive the reply, and return the reply code.  Remember, it is up
    969      * to you to manage the data connection.  If you don't need this low
    970      * level of access, use <a href="org.apache.commons.net.ftp.FTPClient.html">
    971      * FTPClient</a>, which will handle all low level details for you.
    972      * <p>
    973      * @return The reply code received from the server.
    974      * @exception FTPConnectionClosedException
    975      *      If the FTP server prematurely closes the connection as a result
    976      *      of the client being idle or some other reason causing the server
    977      *      to send FTP reply code 421.  This exception may be caught either
    978      *      as an IOException or independently as itself.
    979      * @exception IOException  If an I/O error occurs while either sending the
    980      *      command or receiving the server reply.
    981      ***/
    982     public int stou() throws IOException
    983     {
    984         return sendCommand(FTPCommand.STOU);
    985     }
    986
    987     /****
    988      * A convenience method to send the FTP STOU command to the server,
    989      * receive the reply, and return the reply code.  Remember, it is up
    990      * to you to manage the data connection.  If you don't need this low
    991      * level of access, use <a href="org.apache.commons.net.ftp.FTPClient.html">
    992      * FTPClient</a>, which will handle all low level details for you.
    993      * <p>
    994      * @param pathname  The base pathname to use for the file when stored at
    995      *                  the remote end of the transfer.  Some FTP servers
    996      *                  require this.
    997      * @return The reply code received from the server.
    998      * @exception FTPConnectionClosedException
    999      *      If the FTP server prematurely closes the connection as a result
    1000      *      of the client being idle or some other reason causing the server
    1001      *      to send FTP reply code 421.  This exception may be caught either
    1002      *      as an IOException or independently as itself.
    1003      * @exception IOException  If an I/O error occurs while either sending the
    1004      *      command or receiving the server reply.
    1005      ***/
    1006     public int stou(String filename) throws IOException
    1007     {
    1008         return sendCommand(FTPCommand.STOU, filename);
    1009     }
    1010
    1011     /****
    1012      * A convenience method to send the FTP APPE command to the server,
    1013      * receive the reply, and return the reply code.  Remember, it is up
    1014      * to you to manage the data connection.  If you don't need this low
    1015      * level of access, use <a href="org.apache.commons.net.ftp.FTPClient.html">
    1016      * FTPClient</a>, which will handle all low level details for you.
    1017      * <p>
    1018      * @param pathname  The pathname to use for the file when stored at
    1019      *                  the remote end of the transfer.
    1020      * @return The reply code received from the server.
    1021      * @exception FTPConnectionClosedException
    1022      *      If the FTP server prematurely closes the connection as a result
    1023      *      of the client being idle or some other reason causing the server
    1024      *      to send FTP reply code 421.  This exception may be caught either
    1025      *      as an IOException or independently as itself.
    1026      * @exception IOException  If an I/O error occurs while either sending the
    1027      *      command or receiving the server reply.
    1028      ***/
    1029     public int appe(String pathname) throws IOException
    1030     {
    1031         return sendCommand(FTPCommand.APPE, pathname);
    1032     }
    1033
    1034     /****
    1035      * A convenience method to send the FTP ALLO command to the server,
    1036      * receive the reply, and return the reply code.
    1037      * <p>
    1038      * @param bytes The number of bytes to allocate.
    1039      * @return The reply code received from the server.
    1040      * @exception FTPConnectionClosedException
    1041      *      If the FTP server prematurely closes the connection as a result
    1042      *      of the client being idle or some other reason causing the server
    1043      *      to send FTP reply code 421.  This exception may be caught either
    1044      *      as an IOException or independently as itself.
    1045      * @exception IOException  If an I/O error occurs while either sending the
    1046      *      command or receiving the server reply.
    1047      ***/
    1048     public int allo(int bytes) throws IOException
    1049     {
    1050         return sendCommand(FTPCommand.ALLO, Integer.toString(bytes));
    1051     }
    1052
    1053     /****
    1054      * A convenience method to send the FTP ALLO command to the server,
    1055      * receive the reply, and return the reply code.
    1056      * <p>
    1057      * @param bytes The number of bytes to allocate.
    1058      * @param recordSize  The size of a record.
    1059      * @return The reply code received from the server.
    1060      * @exception FTPConnectionClosedException
    1061      *      If the FTP server prematurely closes the connection as a result
    1062      *      of the client being idle or some other reason causing the server
    1063      *      to send FTP reply code 421.  This exception may be caught either
    1064      *      as an IOException or independently as itself.
    1065      * @exception IOException  If an I/O error occurs while either sending the
    1066      *      command or receiving the server reply.
    1067      ***/
    1068     public int allo(int bytes, int recordSize) throws IOException
    1069     {
    1070         return sendCommand(FTPCommand.ALLO, Integer.toString(bytes) + " R " +
    1071                            Integer.toString(recordSize));
    1072     }
    1073
    1074     /****
    1075      * A convenience method to send the FTP REST command to the server,
    1076      * receive the reply, and return the reply code.
    1077      * <p>
    1078      * @param marker The marker at which to restart a transfer.
    1079      * @return The reply code received from the server.
    1080      * @exception FTPConnectionClosedException
    1081      *      If the FTP server prematurely closes the connection as a result
    1082      *      of the client being idle or some other reason causing the server
    1083      *      to send FTP reply code 421.  This exception may be caught either
    1084      *      as an IOException or independently as itself.
    1085      * @exception IOException  If an I/O error occurs while either sending the
    1086      *      command or receiving the server reply.
    1087      ***/
    1088     public int rest(String marker) throws IOException
    1089     {
    1090         return sendCommand(FTPCommand.REST, marker);
    1091     }
    1092
    1093     /****
    1094      * A convenience method to send the FTP RNFR command to the server,
    1095      * receive the reply, and return the reply code.
    1096      * <p>
    1097      * @param pathname The pathname to rename from.
    1098      * @return The reply code received from the server.
    1099      * @exception FTPConnectionClosedException
    1100      *      If the FTP server prematurely closes the connection as a result
    1101      *      of the client being idle or some other reason causing the server
    1102      *      to send FTP reply code 421.  This exception may be caught either
    1103      *      as an IOException or independently as itself.
    1104      * @exception IOException  If an I/O error occurs while either sending the
    1105      *      command or receiving the server reply.
    1106      ***/
    1107     public int rnfr(String pathname) throws IOException
    1108     {
    1109         return sendCommand(FTPCommand.RNFR, pathname);
    1110     }
    1111
    1112     /****
    1113      * A convenience method to send the FTP RNTO command to the server,
    1114      * receive the reply, and return the reply code.
    1115      * <p>
    1116      * @param pathname The pathname to rename to
    1117      * @return The reply code received from the server.
    1118      * @exception FTPConnectionClosedException
    1119      *      If the FTP server prematurely closes the connection as a result
    1120      *      of the client being idle or some other reason causing the server
    1121      *      to send FTP reply code 421.  This exception may be caught either
    1122      *      as an IOException or independently as itself.
    1123      * @exception IOException  If an I/O error occurs while either sending the
    1124      *      command or receiving the server reply.
    1125      ***/
    1126     public int rnto(String pathname) throws IOException
    1127     {
    1128         return sendCommand(FTPCommand.RNTO, pathname);
    1129     }
    1130
    1131     /****
    1132      * A convenience method to send the FTP DELE command to the server,
    1133      * receive the reply, and return the reply code.
    1134      * <p>
    1135      * @param pathname The pathname to delete.
    1136      * @return The reply code received from the server.
    1137      * @exception FTPConnectionClosedException
    1138      *      If the FTP server prematurely closes the connection as a result
    1139      *      of the client being idle or some other reason causing the server
    1140      *      to send FTP reply code 421.  This exception may be caught either
    1141      *      as an IOException or independently as itself.
    1142      * @exception IOException  If an I/O error occurs while either sending the
    1143      *      command or receiving the server reply.
    1144      ***/
    1145     public int dele(String pathname) throws IOException
    1146     {
    1147         return sendCommand(FTPCommand.DELE, pathname);
    1148     }
    1149
    1150     /****
    1151      * A convenience method to send the FTP RMD command to the server,
    1152      * receive the reply, and return the reply code.
    1153      * <p>
    1154      * @param pathname The pathname of the directory to remove.
    1155      * @return The reply code received from the server.
    1156      * @exception FTPConnectionClosedException
    1157      *      If the FTP server prematurely closes the connection as a result
    1158      *      of the client being idle or some other reason causing the server
    1159      *      to send FTP reply code 421.  This exception may be caught either
    1160      *      as an IOException or independently as itself.
    1161      * @exception IOException  If an I/O error occurs while either sending the
    1162      *      command or receiving the server reply.
    1163      ***/
    1164     public int rmd(String pathname) throws IOException
    1165     {
    1166         return sendCommand(FTPCommand.RMD, pathname);
    1167     }
    1168
    1169     /****
    1170      * A convenience method to send the FTP MKD command to the server,
    1171      * receive the reply, and return the reply code.
    1172      * <p>
    1173      * @param pathname The pathname of the new directory to create.
    1174      * @return The reply code received from the server.
    1175      * @exception FTPConnectionClosedException
    1176      *      If the FTP server prematurely closes the connection as a result
    1177      *      of the client being idle or some other reason causing the server
    1178      *      to send FTP reply code 421.  This exception may be caught either
    1179      *      as an IOException or independently as itself.
    1180      * @exception IOException  If an I/O error occurs while either sending the
    1181      *      command or receiving the server reply.
    1182      ***/
    1183     public int mkd(String pathname) throws IOException
    1184     {
    1185         return sendCommand(FTPCommand.MKD, pathname);
    1186     }
    1187
    1188     /****
    1189      * A convenience method to send the FTP PWD command to the server,
    1190      * receive the reply, and return the reply code.
    1191      * <p>
    1192      * @return The reply code received from the server.
    1193      * @exception FTPConnectionClosedException
    1194      *      If the FTP server prematurely closes the connection as a result
    1195      *      of the client being idle or some other reason causing the server
    1196      *      to send FTP reply code 421.  This exception may be caught either
    1197      *      as an IOException or independently as itself.
    1198      * @exception IOException  If an I/O error occurs while either sending the
    1199      *      command or receiving the server reply.
    1200      ***/
    1201     public int pwd() throws IOException
    1202     {
    1203         return sendCommand(FTPCommand.PWD);
    1204     }
    1205
    1206     /****
    1207      * A convenience method to send the FTP LIST command to the server,
    1208      * receive the reply, and return the reply code.  Remember, it is up
    1209      * to you to manage the data connection.  If you don't need this low
    1210      * level of access, use <a href="org.apache.commons.net.ftp.FTPClient.html">
    1211      * FTPClient</a>, which will handle all low level details for you.
    1212      * <p>
    1213      * @return The reply code received from the server.
    1214      * @exception FTPConnectionClosedException
    1215      *      If the FTP server prematurely closes the connection as a result
    1216      *      of the client being idle or some other reason causing the server
    1217      *      to send FTP reply code 421.  This exception may be caught either
    1218      *      as an IOException or independently as itself.
    1219      * @exception IOException  If an I/O error occurs while either sending the
    1220      *      command or receiving the server reply.
    1221      ***/
    1222     public int list() throws IOException
    1223     {
    1224         return sendCommand(FTPCommand.LIST);
    1225     }
    1226
    1227     /****
    1228      * A convenience method to send the FTP LIST command to the server,
    1229      * receive the reply, and return the reply code.  Remember, it is up
    1230      * to you to manage the data connection.  If you don't need this low
    1231      * level of access, use <a href="org.apache.commons.net.ftp.FTPClient.html">
    1232      * FTPClient</a>, which will handle all low level details for you.
    1233      * <p>
    1234      * @param pathname  The pathname to list.
    1235      * @return The reply code received from the server.
    1236      * @exception FTPConnectionClosedException
    1237      *      If the FTP server prematurely closes the connection as a result
    1238      *      of the client being idle or some other reason causing the server
    1239      *      to send FTP reply code 421.  This exception may be caught either
    1240      *      as an IOException or independently as itself.
    1241      * @exception IOException  If an I/O error occurs while either sending the
    1242      *      command or receiving the server reply.
    1243      ***/
    1244     public int list(String pathname) throws IOException
    1245     {
    1246         return sendCommand(FTPCommand.LIST, pathname);
    1247     }
    1248
    1249     /****
    1250      * A convenience method to send the FTP NLST command to the server,
    1251      * receive the reply, and return the reply code.  Remember, it is up
    1252      * to you to manage the data connection.  If you don't need this low
    1253      * level of access, use <a href="org.apache.commons.net.ftp.FTPClient.html">
    1254      * FTPClient</a>, which will handle all low level details for you.
    1255      * <p>
    1256      * @return The reply code received from the server.
    1257      * @exception FTPConnectionClosedException
    1258      *      If the FTP server prematurely closes the connection as a result
    1259      *      of the client being idle or some other reason causing the server
    1260      *      to send FTP reply code 421.  This exception may be caught either
    1261      *      as an IOException or independently as itself.
    1262      * @exception IOException  If an I/O error occurs while either sending the
    1263      *      command or receiving the server reply.
    1264      ***/
    1265     public int nlst() throws IOException
    1266     {
    1267         return sendCommand(FTPCommand.NLST);
    1268     }
    1269
    1270     /****
    1271      * A convenience method to send the FTP NLST command to the server,
    1272      * receive the reply, and return the reply code.  Remember, it is up
    1273      * to you to manage the data connection.  If you don't need this low
    1274      * level of access, use <a href="org.apache.commons.net.ftp.FTPClient.html">
    1275      * FTPClient</a>, which will handle all low level details for you.
    1276      * <p>
    1277      * @param pathname  The pathname to list.
    1278      * @return The reply code received from the server.
    1279      * @exception FTPConnectionClosedException
    1280      *      If the FTP server prematurely closes the connection as a result
    1281      *      of the client being idle or some other reason causing the server
    1282      *      to send FTP reply code 421.  This exception may be caught either
    1283      *      as an IOException or independently as itself.
    1284      * @exception IOException  If an I/O error occurs while either sending the
    1285      *      command or receiving the server reply.
    1286      ***/
    1287     public int nlst(String pathname) throws IOException
    1288     {
    1289         return sendCommand(FTPCommand.NLST, pathname);
    1290     }
    1291
    1292     /****
    1293      * A convenience method to send the FTP SITE command to the server,
    1294      * receive the reply, and return the reply code.
    1295      * <p>
    1296      * @param parameters  The site parameters to send.
    1297      * @return The reply code received from the server.
    1298      * @exception FTPConnectionClosedException
    1299      *      If the FTP server prematurely closes the connection as a result
    1300      *      of the client being idle or some other reason causing the server
    1301      *      to send FTP reply code 421.  This exception may be caught either
    1302      *      as an IOException or independently as itself.
    1303      * @exception IOException  If an I/O error occurs while either sending the
    1304      *      command or receiving the server reply.
    1305      ***/
    1306     public int site(String parameters) throws IOException
    1307     {
    1308         return sendCommand(FTPCommand.SITE, parameters);
    1309     }
    1310
    1311     /****
    1312      * A convenience method to send the FTP SYST command to the server,
    1313      * receive the reply, and return the reply code.
    1314      * <p>
    1315      * @return The reply code received from the server.
    1316      * @exception FTPConnectionClosedException
    1317      *      If the FTP server prematurely closes the connection as a result
    1318      *      of the client being idle or some other reason causing the server
    1319      *      to send FTP reply code 421.  This exception may be caught either
    1320      *      as an IOException or independently as itself.
    1321      * @exception IOException  If an I/O error occurs while either sending the
    1322      *      command or receiving the server reply.
    1323      ***/
    1324     public int syst() throws IOException
    1325     {
    1326         return sendCommand(FTPCommand.SYST);
    1327     }
    1328
    1329     /****
    1330      * A convenience method to send the FTP STAT command to the server,
    1331      * receive the reply, and return the reply code.
    1332      * <p>
    1333      * @return The reply code received from the server.
    1334      * @exception FTPConnectionClosedException
    1335      *      If the FTP server prematurely closes the connection as a result
    1336      *      of the client being idle or some other reason causing the server
    1337      *      to send FTP reply code 421.  This exception may be caught either
    1338      *      as an IOException or independently as itself.
    1339      * @exception IOException  If an I/O error occurs while either sending the
    1340      *      command or receiving the server reply.
    1341      ***/
    1342     public int stat() throws IOException
    1343     {
    1344         return sendCommand(FTPCommand.STAT);
    1345     }
    1346
    1347     /****
    1348      * A convenience method to send the FTP STAT command to the server,
    1349      * receive the reply, and return the reply code.
    1350      * <p>
    1351      * @param pathname  A pathname to list.
    1352      * @return The reply code received from the server.
    1353      * @exception FTPConnectionClosedException
    1354      *      If the FTP server prematurely closes the connection as a result
    1355      *      of the client being idle or some other reason causing the server
    1356      *      to send FTP reply code 421.  This exception may be caught either
    1357      *      as an IOException or independently as itself.
    1358      * @exception IOException  If an I/O error occurs while either sending the
    1359      *      command or receiving the server reply.
    1360      ***/
    1361     public int stat(String pathname) throws IOException
    1362     {
    1363         return sendCommand(FTPCommand.STAT, pathname);
    1364     }
    1365
    1366     /****
    1367      * A convenience method to send the FTP HELP command to the server,
    1368      * receive the reply, and return the reply code.
    1369      * <p>
    1370      * @return The reply code received from the server.
    1371      * @exception FTPConnectionClosedException
    1372      *      If the FTP server prematurely closes the connection as a result
    1373      *      of the client being idle or some other reason causing the server
    1374      *      to send FTP reply code 421.  This exception may be caught either
    1375      *      as an IOException or independently as itself.
    1376      * @exception IOException  If an I/O error occurs while either sending the
    1377      *      command or receiving the server reply.
    1378      ***/
    1379     public int help() throws IOException
    1380     {
    1381         return sendCommand(FTPCommand.HELP);
    1382     }
    1383
    1384     /****
    1385      * A convenience method to send the FTP HELP command to the server,
    1386      * receive the reply, and return the reply code.
    1387      * <p>
    1388      * @param command  The command name on which to request help.
    1389      * @return The reply code received from the server.
    1390      * @exception FTPConnectionClosedException
    1391      *      If the FTP server prematurely closes the connection as a result
    1392      *      of the client being idle or some other reason causing the server
    1393      *      to send FTP reply code 421.  This exception may be caught either
    1394      *      as an IOException or independently as itself.
    1395      * @exception IOException  If an I/O error occurs while either sending the
    1396      *      command or receiving the server reply.
    1397      ***/
    1398     public int help(String command) throws IOException
    1399     {
    1400         return sendCommand(FTPCommand.HELP, command);
    1401     }
    1402
    1403     /****
    1404      * A convenience method to send the FTP NOOP command to the server,
    1405      * receive the reply, and return the reply code.
    1406      * <p>
    1407      * @return The reply code received from the server.
    1408      * @exception FTPConnectionClosedException
    1409      *      If the FTP server prematurely closes the connection as a result
    1410      *      of the client being idle or some other reason causing the server
    1411      *      to send FTP reply code 421.  This exception may be caught either
    1412      *      as an IOException or independently as itself.
    1413      * @exception IOException  If an I/O error occurs while either sending the
    1414      *      command or receiving the server reply.
    1415      ***/
    1416     public int noop() throws IOException
    1417     {
    1418         return sendCommand(FTPCommand.NOOP);
    1419     }
    1420
    1421 }

This page was automatically generated by Maven