Example usage for org.apache.commons.net.ftp FTPCmd TYPE

List of usage examples for org.apache.commons.net.ftp FTPCmd TYPE

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPCmd TYPE.

Prototype

FTPCmd TYPE

To view the source code for org.apache.commons.net.ftp FTPCmd TYPE.

Click Source Link

Usage

From source file:com.atomicleopard.thundr.ftp.commons.FTP.java

/**
 * A convenience method to send the FTP TYPE command for text files
 * to the server, receive the reply, and return the reply code.
 * @param fileType  The type of the file (one of the <code>FILE_TYPE</code>
 *              constants)./*from   w ww . j ava  2s  . c  o  m*/
 * @param formatOrByteSize  The format of the file (one of the
 *              <code>_FORMAT</code> constants.  In the case of
 *              <code>LOCAL_FILE_TYPE</code>, the byte size.
 * @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, int formatOrByteSize) throws IOException {
    StringBuilder arg = new StringBuilder();

    arg.append(__modes.charAt(fileType));
    arg.append(' ');
    if (fileType == LOCAL_FILE_TYPE) {
        arg.append(formatOrByteSize);
    } else {
        arg.append(__modes.charAt(formatOrByteSize));
    }

    return sendCommand(FTPCmd.TYPE, arg.toString());
}

From source file:com.atomicleopard.thundr.ftp.commons.FTP.java

/**
 * A convenience method to send the FTP TYPE command to the server,
 * receive the reply, and return the reply code.
 * <p>/*ww  w .  jav  a  2  s .co  m*/
 * @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(FTPCmd.TYPE, __modes.substring(fileType, fileType + 1));
}