0

我正在研究 java ftp-client 的一些代码,在一种方法中 this.-operator 被使用,我不知道是什么意思。“this.processFtpRequest”代表什么?

     * Initializes the FTP control connection.
 * @param alias the user-ID
 * @param binaryMode true for binary transmission, false for ASCII
 * @throws SecurityException if the given alias or password is invalid
 * @throws IOException if there is an I/O related problem
 */
private synchronized void initialize(final String alias, final String password, final boolean binaryMode) throws IOException {
    FtpResponse ftpResponse = FtpResponse.parse(this.controlConnectionSource);
    Logger.getGlobal().log(Level.INFO, ftpResponse.toString());
    if (ftpResponse.getCode() != 220) throw new ProtocolException(ftpResponse.toString());

    ftpResponse = this.processFtpRequest("USER " + (alias == null ? "guest" : alias));
    if (ftpResponse.getCode() == 331) {
        ftpResponse = this.processFtpRequest("PASS " + (password == null ? "" : password));
    }
    if (ftpResponse.getCode() != 230) throw new SecurityException(ftpResponse.toString());

    ftpResponse = this.processFtpRequest("TYPE " + (binaryMode ? "I" : "A"));
    if (ftpResponse.getCode() != 200) throw new ProtocolException(ftpResponse.toString());
}
4

1 回答 1

4

来自Java 教程

在实例方法或构造函数中,this是对当前对象的引用——正在调用其方法或构造函数的对象。您可以使用 . 从实例方法或构造函数中引用当前对象的任何成员this

所以this.processFtpRequest(...)调用当前对象的实例方法

于 2013-05-06T21:22:46.250 回答