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