* to be appended. * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient appendFile(String name, InputStream local) throws FtpProtocolException, IOException; /** * Renames a file on the server. * * @param from the name of the file being renamed * @param to the new name for the file * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient rename(String from, String to) throws FtpProtocolException, IOException; /** * Deletes a file on the server. * * @param name a {@code String} containing the name of the file * to delete. * @return this FtpClient * @throws IOException if an error occured during the exchange * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient deleteFile(String name) throws FtpProtocolException, IOException; /** * Creates a new directory on the server. * * @param name a {@code String} containing the name of the directory * to create. * @return this FtpClient * @throws IOException if an error occured during the exchange * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient makeDirectory(String name) throws FtpProtocolException, IOException; /** * Removes a directory on the server. * * @param name a {@code String} containing the name of the directory * to remove. * * @return this FtpClient * @throws IOException if an error occured during the exchange. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient removeDirectory(String name) throws FtpProtocolException, IOException; /** * Sends a No-operation command. It's useful for testing the connection * status or as a <I>keep alive</I> mechanism. * * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient noop() throws FtpProtocolException, IOException; /** * Sends the {@code STAT} command to the server. * This can be used while a data connection is open to get a status * on the current transfer, in that case the parameter should be * {@code null}. * If used between file transfers, it may have a pathname as argument * in which case it will work as the LIST command except no data * connection will be created. * * @param name an optional {@code String} containing the pathname * the STAT command should apply to. * @return the response from the server * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract String getStatus(String name) throws FtpProtocolException, IOException; /** * Sends the {@code FEAT} command to the server and returns the list of supported * features in the form of strings. * * The features are the supported commands, like AUTH TLS, PROT or PASV. * See the RFCs for a complete list. * * Note that not all FTP servers support that command, in which case * a {@link FtpProtocolException} will be thrown. * * @return a {@code List} of {@code Strings} describing the * supported additional features * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command is rejected by the server */ public abstract List<String> getFeatures() throws FtpProtocolException, IOException; /** * Sends the {@code ABOR} command to the server. * <p>It tells the server to stop the previous command or transfer. No action * will be taken if the previous command has already been completed.</p> * <p>This doesn't abort the current session, more commands can be issued * after an abort.</p> * * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient abort() throws FtpProtocolException, IOException; /** * Some methods do not wait until completion before returning, so this * method can be called to wait until completion. This is typically the case * with commands that trigger a transfer like {@link #getFileStream(String)}. * So this method should be called before accessing information related to * such a command. * <p>This method will actually block reading on the command channel for a * notification from the server that the command is finished. Such a * notification often carries extra information concerning the completion * of the pending action (e.g. number of bytes transfered).</p> * <p>Note that this will return immediately if no command or action * is pending</p> * <p>It should be also noted that most methods issuing commands to the ftp * server will call this method if a previous command is pending. * <p>Example of use: * <pre> * InputStream in = cl.getFileStream("file"); * ... * cl.completePending(); * long size = cl.getLastTransferSize(); * </pre> * On the other hand, it's not necessary in a case like: * <pre> * InputStream in = cl.getFileStream("file"); * // read content * ... * cl.close(); * </pre> * <p>Since {@link #close()} will call completePending() if necessary.</p> * @return this FtpClient * @throws IOException if an error occured during the transfer * @throws FtpProtocolException if the command didn't complete successfully */ public abstract FtpClient completePending() throws FtpProtocolException, IOException; /** * Reinitializes the USER parameters on the FTP server * * @return this FtpClient * @throws IOException if an error occurs during transmission * @throws FtpProtocolException if the command fails */ public abstract FtpClient reInit() throws FtpProtocolException, IOException; /** * Changes the transfer type (binary, ascii, ebcdic) and issue the * proper command (e.g. TYPE A) to the server. * * @param type the {@code TransferType} to use. * @return This FtpClient * @throws IOException if an error occurs during transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient setType(TransferType type) throws FtpProtocolException, IOException; /** * Changes the current transfer type to binary. * This is a convenience method that is equivalent to * {@code setType(TransferType.BINARY)} * * @return This FtpClient * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #setType(TransferType) */ public FtpClient setBinaryType() throws FtpProtocolException, IOException { setType(TransferType.BINARY); return this; } /** * Changes the current transfer type to ascii. * This is a convenience method that is equivalent to * {@code setType(TransferType.ASCII)} * * @return This FtpClient * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #setType(TransferType) */ public FtpClient setAsciiType() throws FtpProtocolException, IOException { setType(TransferType.ASCII); return this; } /** * Issues a {@code LIST} command to the server to get the current directory * listing, and returns the InputStream from the data connection. * * <p>{@link #completePending()} <b>has</b> to be called once the application * is finished reading from the stream.</p> * * @param path the pathname of the directory to list, or {@code null} * for the current working directory. * @return the {@code InputStream} from the resulting data connection * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #changeDirectory(String) * @see #listFiles(String) */ public abstract InputStream list(String path) throws FtpProtocolException, IOException; /** * Issues a {@code NLST path} command to server to get the specified directory * content. It differs from {@link #list(String)} method by the fact that * it will only list the file names which would make the parsing of the * somewhat easier. * * <p>{@link #completePending()} <b>has</b> to be called once the application * is finished reading from the stream.</p> * * @param path a {@code String} containing the pathname of the * directory to list or {@code null} for the current working directory. * @return the {@code InputStream} from the resulting data connection * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract InputStream nameList(String path) throws FtpProtocolException, IOException; /** * Issues the {@code SIZE [path]} command to the server to get the size of a * specific file on the server. * Note that this command may not be supported by the server. In which * case -1 will be returned. * * @param path a {@code String} containing the pathname of the * file. * @return a {@code long} containing the size of the file or -1 if * the server returned an error, which can be checked with * {@link #getLastReplyCode()}. * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract long getSize(String path) throws FtpProtocolException, IOException; /** * Issues the {@code MDTM [path]} command to the server to get the modification * time of a specific file on the server. * Note that this command may not be supported by the server, in which * case {@code null} will be returned. * * @param path a {@code String} containing the pathname of the file. * @return a {@code Date} representing the last modification time * or {@code null} if the server returned an error, which * can be checked with {@link #getLastReplyCode()}. * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract Date getLastModified(String path) throws FtpProtocolException, IOException; /** * Sets the parser used to handle the directory output to the specified * one. By default the parser is set to one that can handle most FTP * servers output (Unix base mostly). However it may be necessary for * and application to provide its own parser due to some uncommon * output format. * * @param p The {@code FtpDirParser} to use. * @return this FtpClient * @see #listFiles(String) */ public abstract FtpClient setDirParser(FtpDirParser p); /** * Issues a {@code MLSD} command to the server to get the specified directory * listing and applies the internal parser to create an Iterator of * {@link java.net.FtpDirEntry}. Note that the Iterator returned is also a * {@link java.io.Closeable}. * <p>If the server doesn't support the MLSD command, the LIST command is used * instead and the parser set by {@link #setDirParser(java.net.FtpDirParser) } * is used instead.</p> * * {@link #completePending()} <b>has</b> to be called once the application * is finished iterating through the files. * * @param path the pathname of the directory to list or {@code null} * for the current working directoty. * @return a {@code Iterator} of files or {@code null} if the * command failed. * @throws IOException if an error occured during the transmission * @see #setDirParser(FtpDirParser) * @see #changeDirectory(String) * @throws FtpProtocolException if the command was rejected by the server */ public abstract Iterator<FtpDirEntry> listFiles(String path) throws FtpProtocolException, IOException; /** * Attempts to use Kerberos GSSAPI as an authentication mechanism with the * ftp server. This will issue an {@code AUTH GSSAPI} command, and if * it is accepted by the server, will followup with {@code ADAT} * command to exchange the various tokens until authentication is * successful. This conforms to Appendix I of RFC 2228. * * @return this FtpClient * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient useKerberos() throws FtpProtocolException, IOException; /** * Returns the Welcome string the server sent during initial connection. * * @return a {@code String} containing the message the server * returned during connection or {@code null}. */ public abstract String getWelcomeMsg(); /** * Returns the last reply code sent by the server. * * @return the lastReplyCode or {@code null} if none were received yet. */ public abstract FtpReplyCode getLastReplyCode(); /** * Returns the last response string sent by the server. * * @return the message string, which can be quite long, last returned * by the server, or {@code null} if no response were received yet. */ public abstract String getLastResponseString(); /** * Returns, when available, the size of the latest started transfer. * This is retreived by parsing the response string received as an initial * response to a {@code RETR} or similar request. * * @return the size of the latest transfer or -1 if either there was no * transfer or the information was unavailable. */ public abstract long getLastTransferSize(); /** * Returns, when available, the remote name of the last transfered file. * This is mainly useful for "put" operation when the unique flag was * set since it allows to recover the unique file name created on the * server which may be different from the one submitted with the command. * * @return the name the latest transfered file remote name, or * {@code null} if that information is unavailable. */ public abstract String getLastFileName(); /** * Attempts to switch to a secure, encrypted connection. This is done by * sending the {@code AUTH TLS} command. * <p>See <a href="http://www.ietf.org/rfc/rfc4217.txt">RFC 4217</a></p> * If successful this will establish a secure command channel with the * server, it will also make it so that all other transfers (e.g. a RETR * command) will be done over an encrypted channel as well unless a * {@link #reInit()} command or a {@link #endSecureSession()} command is issued. * <p>This method should be called after a successful {@link #connect(java.net.InetSocketAddress) } * but before calling {@link #login(java.lang.String, char[]) }.</p> * * @return this FtpCLient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #endSecureSession() */ public abstract FtpClient startSecureSession() throws FtpProtocolException, IOException; /** * Sends a {@code CCC} command followed by a {@code PROT C} * command to the server terminating an encrypted session and reverting * back to a non encrypted transmission. * * @return this FtpClient * @throws IOException if an error occured during transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #startSecureSession() */ public abstract FtpClient endSecureSession() throws FtpProtocolException, IOException; /** * Sends the "Allocate" ({@code ALLO}) command to the server telling it to * pre-allocate the specified number of bytes for the next transfer. * * @param size The number of bytes to allocate. * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient allocate(long size) throws FtpProtocolException, IOException; /** * Sends the "Structure Mount" ({@code SMNT}) command to the server. This let the * user mount a different file system data structure without altering his * login or accounting information. * * @param struct a {@code String} containing the name of the * structure to mount. * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient structureMount(String struct) throws FtpProtocolException, IOException; /** * Sends a System ({@code SYST}) command to the server and returns the String * sent back by the server describing the operating system at the * server. * * @return a {@code String} describing the OS, or {@code null} * if the operation was not successful. * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract String getSystem() throws FtpProtocolException, IOException; /** * Sends the {@code HELP} command to the server, with an optional command, like * SITE, and returns the text sent back by the server. * * @param cmd the command for which the help is requested or * {@code null} for the general help * @return a {@code String} containing the text sent back by the * server, or {@code null} if the command failed. * @throws IOException if an error occured during transmission * @throws FtpProtocolException if the command was rejected by the server */ public abstract String getHelp(String cmd) throws FtpProtocolException, IOException; /** * Sends the {@code SITE} command to the server. This is used by the server * to provide services specific to his system that are essential * to file transfer. * * @param cmd the command to be sent. * @return this FtpClient * @throws IOException if an error occured during transmission * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient siteCmd(String cmd) throws FtpProtocolException, IOException;}Lines 501–943 of 943. Previous lines
* to be appended. * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient appendFile(String name, InputStream local) throws FtpProtocolException, IOException; /** * Renames a file on the server. * * @param from the name of the file being renamed * @param to the new name for the file * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient rename(String from, String to) throws FtpProtocolException, IOException; /** * Deletes a file on the server. * * @param name a {@code String} containing the name of the file * to delete. * @return this FtpClient * @throws IOException if an error occured during the exchange * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient deleteFile(String name) throws FtpProtocolException, IOException; /** * Creates a new directory on the server. * * @param name a {@code String} containing the name of the directory * to create. * @return this FtpClient * @throws IOException if an error occured during the exchange * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient makeDirectory(String name) throws FtpProtocolException, IOException; /** * Removes a directory on the server. * * @param name a {@code String} containing the name of the directory * to remove. * * @return this FtpClient * @throws IOException if an error occured during the exchange. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient removeDirectory(String name) throws FtpProtocolException, IOException; /** * Sends a No-operation command. It's useful for testing the connection * status or as a <I>keep alive</I> mechanism. * * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient noop() throws FtpProtocolException, IOException; /** * Sends the {@code STAT} command to the server. * This can be used while a data connection is open to get a status * on the current transfer, in that case the parameter should be * {@code null}. * If used between file transfers, it may have a pathname as argument * in which case it will work as the LIST command except no data * connection will be created. * * @param name an optional {@code String} containing the pathname * the STAT command should apply to. * @return the response from the server * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract String getStatus(String name) throws FtpProtocolException, IOException; /** * Sends the {@code FEAT} command to the server and returns the list of supported * features in the form of strings. * * The features are the supported commands, like AUTH TLS, PROT or PASV. * See the RFCs for a complete list. * * Note that not all FTP servers support that command, in which case * a {@link FtpProtocolException} will be thrown. * * @return a {@code List} of {@code Strings} describing the * supported additional features * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command is rejected by the server */ public abstract List<String> getFeatures() throws FtpProtocolException, IOException; /** * Sends the {@code ABOR} command to the server. * <p>It tells the server to stop the previous command or transfer. No action * will be taken if the previous command has already been completed.</p> * <p>This doesn't abort the current session, more commands can be issued * after an abort.</p> * * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient abort() throws FtpProtocolException, IOException; /** * Some methods do not wait until completion before returning, so this * method can be called to wait until completion. This is typically the case * with commands that trigger a transfer like {@link #getFileStream(String)}. * So this method should be called before accessing information related to * such a command. * <p>This method will actually block reading on the command channel for a * notification from the server that the command is finished. Such a * notification often carries extra information concerning the completion * of the pending action (e.g. number of bytes transfered).</p> * <p>Note that this will return immediately if no command or action * is pending</p> * <p>It should be also noted that most methods issuing commands to the ftp * server will call this method if a previous command is pending. * <p>Example of use: * <pre> * InputStream in = cl.getFileStream("file"); * ... * cl.completePending(); * long size = cl.getLastTransferSize(); * </pre> * On the other hand, it's not necessary in a case like: * <pre> * InputStream in = cl.getFileStream("file"); * // read content * ... * cl.close(); * </pre> * <p>Since {@link #close()} will call completePending() if necessary.</p> * @return this FtpClient * @throws IOException if an error occured during the transfer * @throws FtpProtocolException if the command didn't complete successfully */ public abstract FtpClient completePending() throws FtpProtocolException, IOException; /** * Reinitializes the USER parameters on the FTP server * * @return this FtpClient * @throws IOException if an error occurs during transmission * @throws FtpProtocolException if the command fails */ public abstract FtpClient reInit() throws FtpProtocolException, IOException; /** * Changes the transfer type (binary, ascii, ebcdic) and issue the * proper command (e.g. TYPE A) to the server. * * @param type the {@code TransferType} to use. * @return This FtpClient * @throws IOException if an error occurs during transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient setType(TransferType type) throws FtpProtocolException, IOException; /** * Changes the current transfer type to binary. * This is a convenience method that is equivalent to * {@code setType(TransferType.BINARY)} * * @return This FtpClient * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #setType(TransferType) */ public FtpClient setBinaryType() throws FtpProtocolException, IOException { setType(TransferType.BINARY); return this; } /** * Changes the current transfer type to ascii. * This is a convenience method that is equivalent to * {@code setType(TransferType.ASCII)} * * @return This FtpClient * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #setType(TransferType) */ public FtpClient setAsciiType() throws FtpProtocolException, IOException { setType(TransferType.ASCII); return this; } /** * Issues a {@code LIST} command to the server to get the current directory * listing, and returns the InputStream from the data connection. * * <p>{@link #completePending()} <b>has</b> to be called once the application * is finished reading from the stream.</p> * * @param path the pathname of the directory to list, or {@code null} * for the current working directory. * @return the {@code InputStream} from the resulting data connection * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #changeDirectory(String) * @see #listFiles(String) */ public abstract InputStream list(String path) throws FtpProtocolException, IOException; /** * Issues a {@code NLST path} command to server to get the specified directory * content. It differs from {@link #list(String)} method by the fact that * it will only list the file names which would make the parsing of the * somewhat easier. * * <p>{@link #completePending()} <b>has</b> to be called once the application * is finished reading from the stream.</p> * * @param path a {@code String} containing the pathname of the * directory to list or {@code null} for the current working directory. * @return the {@code InputStream} from the resulting data connection * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract InputStream nameList(String path) throws FtpProtocolException, IOException; /** * Issues the {@code SIZE [path]} command to the server to get the size of a * specific file on the server. * Note that this command may not be supported by the server. In which * case -1 will be returned. * * @param path a {@code String} containing the pathname of the * file. * @return a {@code long} containing the size of the file or -1 if * the server returned an error, which can be checked with * {@link #getLastReplyCode()}. * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract long getSize(String path) throws FtpProtocolException, IOException; /** * Issues the {@code MDTM [path]} command to the server to get the modification * time of a specific file on the server. * Note that this command may not be supported by the server, in which * case {@code null} will be returned. * * @param path a {@code String} containing the pathname of the file. * @return a {@code Date} representing the last modification time * or {@code null} if the server returned an error, which * can be checked with {@link #getLastReplyCode()}. * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract Date getLastModified(String path) throws FtpProtocolException, IOException; /** * Sets the parser used to handle the directory output to the specified * one. By default the parser is set to one that can handle most FTP * servers output (Unix base mostly). However it may be necessary for * and application to provide its own parser due to some uncommon * output format. * * @param p The {@code FtpDirParser} to use. * @return this FtpClient * @see #listFiles(String) */ public abstract FtpClient setDirParser(FtpDirParser p); /** * Issues a {@code MLSD} command to the server to get the specified directory * listing and applies the internal parser to create an Iterator of * {@link java.net.FtpDirEntry}. Note that the Iterator returned is also a * {@link java.io.Closeable}. * <p>If the server doesn't support the MLSD command, the LIST command is used * instead and the parser set by {@link #setDirParser(java.net.FtpDirParser) } * is used instead.</p> * * {@link #completePending()} <b>has</b> to be called once the application * is finished iterating through the files. * * @param path the pathname of the directory to list or {@code null} * for the current working directoty. * @return a {@code Iterator} of files or {@code null} if the * command failed. * @throws IOException if an error occured during the transmission * @see #setDirParser(FtpDirParser) * @see #changeDirectory(String) * @throws FtpProtocolException if the command was rejected by the server */ public abstract Iterator<FtpDirEntry> listFiles(String path) throws FtpProtocolException, IOException; /** * Attempts to use Kerberos GSSAPI as an authentication mechanism with the * ftp server. This will issue an {@code AUTH GSSAPI} command, and if * it is accepted by the server, will followup with {@code ADAT} * command to exchange the various tokens until authentication is * successful. This conforms to Appendix I of RFC 2228. * * @return this FtpClient * @throws IOException if an error occurs during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient useKerberos() throws FtpProtocolException, IOException; /** * Returns the Welcome string the server sent during initial connection. * * @return a {@code String} containing the message the server * returned during connection or {@code null}. */ public abstract String getWelcomeMsg(); /** * Returns the last reply code sent by the server. * * @return the lastReplyCode or {@code null} if none were received yet. */ public abstract FtpReplyCode getLastReplyCode(); /** * Returns the last response string sent by the server. * * @return the message string, which can be quite long, last returned * by the server, or {@code null} if no response were received yet. */ public abstract String getLastResponseString(); /** * Returns, when available, the size of the latest started transfer. * This is retreived by parsing the response string received as an initial * response to a {@code RETR} or similar request. * * @return the size of the latest transfer or -1 if either there was no * transfer or the information was unavailable. */ public abstract long getLastTransferSize(); /** * Returns, when available, the remote name of the last transfered file. * This is mainly useful for "put" operation when the unique flag was * set since it allows to recover the unique file name created on the * server which may be different from the one submitted with the command. * * @return the name the latest transfered file remote name, or * {@code null} if that information is unavailable. */ public abstract String getLastFileName(); /** * Attempts to switch to a secure, encrypted connection. This is done by * sending the {@code AUTH TLS} command. * <p>See <a href="http://www.ietf.org/rfc/rfc4217.txt">RFC 4217</a></p> * If successful this will establish a secure command channel with the * server, it will also make it so that all other transfers (e.g. a RETR * command) will be done over an encrypted channel as well unless a * {@link #reInit()} command or a {@link #endSecureSession()} command is issued. * <p>This method should be called after a successful {@link #connect(java.net.InetSocketAddress) } * but before calling {@link #login(java.lang.String, char[]) }.</p> * * @return this FtpCLient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #endSecureSession() */ public abstract FtpClient startSecureSession() throws FtpProtocolException, IOException; /** * Sends a {@code CCC} command followed by a {@code PROT C} * command to the server terminating an encrypted session and reverting * back to a non encrypted transmission. * * @return this FtpClient * @throws IOException if an error occured during transmission. * @throws FtpProtocolException if the command was rejected by the server * @see #startSecureSession() */ public abstract FtpClient endSecureSession() throws FtpProtocolException, IOException; /** * Sends the "Allocate" ({@code ALLO}) command to the server telling it to * pre-allocate the specified number of bytes for the next transfer. * * @param size The number of bytes to allocate. * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient allocate(long size) throws FtpProtocolException, IOException; /** * Sends the "Structure Mount" ({@code SMNT}) command to the server. This let the * user mount a different file system data structure without altering his * login or accounting information. * * @param struct a {@code String} containing the name of the * structure to mount. * @return this FtpClient * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient structureMount(String struct) throws FtpProtocolException, IOException; /** * Sends a System ({@code SYST}) command to the server and returns the String * sent back by the server describing the operating system at the * server. * * @return a {@code String} describing the OS, or {@code null} * if the operation was not successful. * @throws IOException if an error occured during the transmission. * @throws FtpProtocolException if the command was rejected by the server */ public abstract String getSystem() throws FtpProtocolException, IOException; /** * Sends the {@code HELP} command to the server, with an optional command, like * SITE, and returns the text sent back by the server. * * @param cmd the command for which the help is requested or * {@code null} for the general help * @return a {@code String} containing the text sent back by the * server, or {@code null} if the command failed. * @throws IOException if an error occured during transmission * @throws FtpProtocolException if the command was rejected by the server */ public abstract String getHelp(String cmd) throws FtpProtocolException, IOException; /** * Sends the {@code SITE} command to the server. This is used by the server * to provide services specific to his system that are essential * to file transfer. * * @param cmd the command to be sent. * @return this FtpClient * @throws IOException if an error occured during transmission * @throws FtpProtocolException if the command was rejected by the server */ public abstract FtpClient siteCmd(String cmd) throws FtpProtocolException, IOException; }