ftp.java

来自「apache推出的net包」· Java 代码 · 共 1,475 行 · 第 1/5 页

JAVA
1,475
字号
     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     */    public int type(int fileType, int formatOrByteSize) throws IOException    {        StringBuffer arg = new StringBuffer();        arg.append(__modes.charAt(fileType));        arg.append(' ');        if (fileType == LOCAL_FILE_TYPE)            arg.append(formatOrByteSize);        else            arg.append(__modes.charAt(formatOrByteSize));        return sendCommand(FTPCommand.TYPE, arg.toString());    }    /**     * A convenience method to send the FTP TYPE command to the server,     * receive the reply, and return the reply code.     * <p>     * @param fileType  The type of the file (one of the <code>FILE_TYPE</code>     *              constants).     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     */    public int type(int fileType) throws IOException    {        return sendCommand(FTPCommand.TYPE,                           __modes.substring(fileType, fileType + 1));    }    /***     * A convenience method to send the FTP STRU command to the server,     * receive the reply, and return the reply code.     * <p>     * @param structure  The structure of the file (one of the     *         <code>_STRUCTURE</code> constants).     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int stru(int structure) throws IOException    {        return sendCommand(FTPCommand.STRU,                           __modes.substring(structure, structure + 1));    }    /***     * A convenience method to send the FTP MODE command to the server,     * receive the reply, and return the reply code.     * <p>     * @param mode  The transfer mode to use (one of the     *         <code>TRANSFER_MODE</code> constants).     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int mode(int mode) throws IOException    {        return sendCommand(FTPCommand.MODE,                           __modes.substring(mode, mode + 1));    }    /***     * A convenience method to send the FTP RETR command to the server,     * receive the reply, and return the reply code.  Remember, it is up     * to you to manage the data connection.  If you don't need this low     * level of access, use {@link org.apache.commons.net.ftp.FTPClient}     * , which will handle all low level details for you.     * <p>     * @param pathname  The pathname of the file to retrieve.     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int retr(String pathname) throws IOException    {        return sendCommand(FTPCommand.RETR, pathname);    }    /***     * A convenience method to send the FTP STOR command to the server,     * receive the reply, and return the reply code.  Remember, it is up     * to you to manage the data connection.  If you don't need this low     * level of access, use {@link org.apache.commons.net.ftp.FTPClient}     * , which will handle all low level details for you.     * <p>     * @param pathname  The pathname to use for the file when stored at     *                  the remote end of the transfer.     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int stor(String pathname) throws IOException    {        return sendCommand(FTPCommand.STOR, pathname);    }    /***     * A convenience method to send the FTP STOU command to the server,     * receive the reply, and return the reply code.  Remember, it is up     * to you to manage the data connection.  If you don't need this low     * level of access, use {@link org.apache.commons.net.ftp.FTPClient}     * , which will handle all low level details for you.     * <p>     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int stou() throws IOException    {        return sendCommand(FTPCommand.STOU);    }    /***     * A convenience method to send the FTP STOU command to the server,     * receive the reply, and return the reply code.  Remember, it is up     * to you to manage the data connection.  If you don't need this low     * level of access, use {@link org.apache.commons.net.ftp.FTPClient}     * , which will handle all low level details for you.     * @param pathname  The base pathname to use for the file when stored at     *                  the remote end of the transfer.  Some FTP servers     *                  require this.     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     */    public int stou(String pathname) throws IOException    {        return sendCommand(FTPCommand.STOU, pathname);    }    /***     * A convenience method to send the FTP APPE command to the server,     * receive the reply, and return the reply code.  Remember, it is up     * to you to manage the data connection.  If you don't need this low     * level of access, use {@link org.apache.commons.net.ftp.FTPClient}     * , which will handle all low level details for you.     * <p>     * @param pathname  The pathname to use for the file when stored at     *                  the remote end of the transfer.     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int appe(String pathname) throws IOException    {        return sendCommand(FTPCommand.APPE, pathname);    }    /***     * A convenience method to send the FTP ALLO command to the server,     * receive the reply, and return the reply code.     * <p>     * @param bytes The number of bytes to allocate.     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int allo(int bytes) throws IOException    {        return sendCommand(FTPCommand.ALLO, Integer.toString(bytes));    }    /***     * A convenience method to send the FTP ALLO command to the server,     * receive the reply, and return the reply code.     * <p>     * @param bytes The number of bytes to allocate.     * @param recordSize  The size of a record.     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int allo(int bytes, int recordSize) throws IOException    {        return sendCommand(FTPCommand.ALLO, Integer.toString(bytes) + " R " +                           Integer.toString(recordSize));    }    /***     * A convenience method to send the FTP REST command to the server,     * receive the reply, and return the reply code.     * <p>     * @param marker The marker at which to restart a transfer.     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int rest(String marker) throws IOException    {        return sendCommand(FTPCommand.REST, marker);    }    /***     * A convenience method to send the FTP RNFR command to the server,     * receive the reply, and return the reply code.     * <p>     * @param pathname The pathname to rename from.     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int rnfr(String pathname) throws IOException    {        return sendCommand(FTPCommand.RNFR, pathname);    }    /***     * A convenience method to send the FTP RNTO command to the server,     * receive the reply, and return the reply code.     * <p>     * @param pathname The pathname to rename to     * @return The reply code received from the server.     * @exception FTPConnectionClosedException     *      If the FTP server prematurely closes the connection as a result     *      of the client being idle or some other reason causing the server     *      to send FTP reply code 421.  This exception may be caught either     *      as an IOException or independently as itself.     * @exception IOException  If an I/O error occurs while either sending the     *      command or receiving the server reply.     ***/    public int rnto(String pathname) throws IOException    {        return sendCommand(FTPCommand.RNTO, pathname);    }    /***     * A convenience method to send the FTP DELE command to the server,     * receive the reply, and return the reply code.     * <p>     * @param pathname The pathname to delete.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?