org.apache.commons.net.ftp.FTPReply.isPositiveCompletion()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(1292)

本文整理了Java中org.apache.commons.net.ftp.FTPReply.isPositiveCompletion()方法的一些代码示例,展示了FTPReply.isPositiveCompletion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FTPReply.isPositiveCompletion()方法的具体详情如下:
包路径:org.apache.commons.net.ftp.FTPReply
类名称:FTPReply
方法名:isPositiveCompletion

FTPReply.isPositiveCompletion介绍

[英]Determine if a reply code is a positive completion response. All codes beginning with a 2 are positive completion responses. The FTP server will send a positive completion response on the final successful completion of a command.
[中]确定回复代码是否为肯定完成响应。所有以2开头的代码都是肯定的完成响应。FTP服务器将在命令最终成功完成时发送肯定的完成响应。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

client.connect(host, port);
int reply = client.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
 throw NetUtils.wrapException(host, port,
        NetUtils.UNKNOWN_HOST, 0,

代码示例来源:origin: looly/hutool

if (false == FTPReply.isPositiveCompletion(replyCode)) {
  try {
    client.disconnect();

代码示例来源:origin: looly/hutool

if (false == FTPReply.isPositiveCompletion(replyCode)) {
  try {
    client.disconnect();

代码示例来源:origin: hs-web/hsweb-framework

public PooledObject<FTPClient> makeObject() throws Exception {
  FTPClient ftpClient = new FTPClient();
  ftpClient.setConnectTimeout(config.getClientTimeout());
  ftpClient.connect(config.getHost(), config.getPort());
  int reply = ftpClient.getReplyCode();
  if (!FTPReply.isPositiveCompletion(reply)) {
    ftpClient.disconnect();
    logger.warn("FTPServer refused connection");
    return null;
  }
  boolean result = ftpClient.login(config.getUsername(), config.getPassword());
  if (!result) {
    throw new ConnectException("ftp登陆失败:" + config.getUsername() + "/password:" + config.getPassword() + "@" + config.getHost());
  }
  ftpClient.setFileType(config.getTransferFileType());
  ftpClient.setBufferSize(1024);
  ftpClient.setControlEncoding(config.getEncoding());
  if (config.isPassiveMode()) {
    ftpClient.enterLocalPassiveMode();
  }
  return new DefaultPooledObject<>(ftpClient);
}

代码示例来源:origin: gotev/android-upload-service

ftpClient.connect(params.serverUrl, ftpParams.port);
if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
  throw new Exception("Can't connect to " + params.serverUrl
            + ":" + ftpParams.port

代码示例来源:origin: commons-net/commons-net

/**
   * @return the name
   * @throws IOException on error
   * @deprecated use {@link #getSystemType()} instead
   */
  @Deprecated
  public String getSystemName() throws IOException
  {
    if (__systemName == null && FTPReply.isPositiveCompletion(syst())) {
      __systemName = _replyLines.get(_replyLines.size() - 1).substring(4);
    }
    return __systemName;
  }
}

代码示例来源:origin: commons-net/commons-net

/**
 * Change to the parent directory of the current working directory.
 *
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean changeToParentDirectory() throws IOException
{
  return FTPReply.isPositiveCompletion(cdup());
}

代码示例来源:origin: commons-net/commons-net

/**
 * Abort a transfer in progress.
 *
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean abort() throws IOException
{
  return FTPReply.isPositiveCompletion(abor());
}

代码示例来源:origin: commons-net/commons-net

/**
 * Send a site specific command.
 * @param arguments The site specific command and arguments.
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean sendSiteCommand(String arguments) throws IOException
{
  return FTPReply.isPositiveCompletion(site(arguments));
}

代码示例来源:origin: commons-net/commons-net

/**
 * Logout of the FTP server by sending the QUIT command.
 *
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean logout() throws IOException
{
  return FTPReply.isPositiveCompletion(quit());
}

代码示例来源:origin: commons-net/commons-net

/**
 * Change the current working directory of the FTP session.
 *
 * @param pathname  The new current working directory.
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean changeWorkingDirectory(String pathname) throws IOException
{
  return FTPReply.isPositiveCompletion(cwd(pathname));
}

代码示例来源:origin: commons-net/commons-net

/**
 * Deletes a file on the FTP server.
 *
 * @param pathname   The pathname of the file to be deleted.
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean deleteFile(String pathname) throws IOException
{
  return FTPReply.isPositiveCompletion(dele(pathname));
}

代码示例来源:origin: commons-net/commons-net

/**
 * Removes a directory on the FTP server (if empty).
 *
 * @param pathname  The pathname of the directory to remove.
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean removeDirectory(String pathname) throws IOException
{
  return FTPReply.isPositiveCompletion(rmd(pathname));
}

代码示例来源:origin: commons-net/commons-net

/**
 * Sends a NOOP command to the FTP server.  This is useful for preventing
 * server timeouts.
 *
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean sendNoOp() throws IOException
{
  return FTPReply.isPositiveCompletion(noop());
}

代码示例来源:origin: commons-net/commons-net

/**
 * Reserve a number of bytes on the server for the next file transfer.
 *
 * @param bytes  The number of bytes which the server should allocate.
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean allocate(int bytes) throws IOException
{
  return FTPReply.isPositiveCompletion(allo(bytes));
}

代码示例来源:origin: commons-net/commons-net

/**
 * Issue the FTP SMNT command.
 *
 * @param pathname The pathname to mount.
 * @return True if successfully completed, false if not.
 * @throws 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.
 * @throws IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean structureMount(String pathname) throws IOException
{
  return FTPReply.isPositiveCompletion(smnt(pathname));
}

代码示例来源:origin: spring-projects/spring-integration

@Override
public boolean finalizeRaw() throws IOException {
  if (!this.readingRaw.compareAndSet(true, false)) {
    throw new IOException("Raw read is not in process");
  }
  if (this.client.completePendingCommand()) {
    int replyCode = this.client.getReplyCode();
    if (this.logger.isDebugEnabled()) {
      this.logger.debug(this + " finalizeRaw - reply code: " + replyCode);
    }
    return FTPReply.isPositiveCompletion(replyCode);
  }
  throw new IOException("completePendingCommandFailed");
}

代码示例来源:origin: commons-net/commons-net

/**
 * Issue the FTP MDTM command (not supported by all servers) to retrieve the last
 * modification time of a file. The modification string should be in the
 * ISO 3077 form "YYYYMMDDhhmmss(.xxx)?". The timestamp represented should also be in
 * GMT, but not all FTP servers honour this.
 *
 * @param pathname The file path to query.
 * @return A string representing the last file modification time in <code>YYYYMMDDhhmmss</code> format.
 * @throws IOException if an I/O error occurs.
 * @since 2.0
 */
public String getModificationTime(String pathname) throws IOException {
  if (FTPReply.isPositiveCompletion(mdtm(pathname))) {
    return getReplyStrings()[0].substring(4); // skip the return code (e.g. 213) and the space
  }
  return null;
}

代码示例来源:origin: 0opslab/opslabJutil

public boolean reply(String operation, String localFile, String remoteFile) {
  int    replyCode = client.getReplyCode();
  FTPLog log       = new FTPLog();
  log.setHost(vo.getHostName());
  log.setOperation(operation);
  log.setLocalFile(localFile);
  log.setRemoteFile(remoteFile);
  log.setReplyCode(replyCode);
  log.setReplyCodeDesc(FTPConstant.REPLYCODE.get(replyCode));
  logger.info(log);
  return FTPReply.isPositiveCompletion(replyCode);
}

代码示例来源:origin: 0opslab/opslabJutil

public boolean reply(String operation) {
  int    replyCode = client.getReplyCode();
  FTPLog log       = new FTPLog();
  log.setHost(vo.getHostName());
  log.setOperation(operation);
  log.setLocalFile("");
  log.setRemoteFile("");
  log.setReplyCode(replyCode);
  log.setReplyCodeDesc(FTPConstant.REPLYCODE.get(replyCode));
  logger.info(log);
  return FTPReply.isPositiveCompletion(replyCode);
}

相关文章