当前位置: 首页>>代码示例>>Java>>正文


Java FTPClient.getReplyString方法代码示例

本文整理汇总了Java中org.apache.commons.net.ftp.FTPClient.getReplyString方法的典型用法代码示例。如果您正苦于以下问题:Java FTPClient.getReplyString方法的具体用法?Java FTPClient.getReplyString怎么用?Java FTPClient.getReplyString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.net.ftp.FTPClient的用法示例。


在下文中一共展示了FTPClient.getReplyString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadFile

import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
/**
 * Upload a single file to FTP server with the provided FTP client object.
 *
 * @param sourceFilePath
 * @param targetFilePath
 * @param logPrefix
 * @throws IOException
 */
protected void uploadFile(final FTPClient ftpClient, final String sourceFilePath, final String targetFilePath,
                          final String logPrefix) throws IOException {
    log.info(String.format(UPLOAD_FILE, logPrefix, sourceFilePath, targetFilePath));
    final File sourceFile = new File(sourceFilePath);
    try (final InputStream is = new FileInputStream(sourceFile)) {
        ftpClient.changeWorkingDirectory(targetFilePath);
        ftpClient.storeFile(sourceFile.getName(), is);

        final int replyCode = ftpClient.getReplyCode();
        final String replyMessage = ftpClient.getReplyString();
        if (isCommandFailed(replyCode)) {
            log.error(String.format(UPLOAD_FILE_REPLY, logPrefix, replyMessage));
            throw new IOException("Failed to upload file: " + sourceFilePath);
        } else {
            log.info(String.format(UPLOAD_FILE_REPLY, logPrefix, replyMessage));
        }
    }
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:27,代码来源:FTPUploader.java

示例2: sendCommands

import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
public void sendCommands(final List<String> commands, final FlowFile flowFile) throws IOException {
    if (commands.isEmpty()) {
        return;
    }

    final FTPClient client = getClient(flowFile);
    for (String cmd : commands) {
        if (!cmd.isEmpty()) {
            int result;
            result = client.sendCommand(cmd);
            logger.debug(this + " sent command to the FTP server: " + cmd + " for " + flowFile);

            if (FTPReply.isNegativePermanent(result) || FTPReply.isNegativeTransient(result)) {
                throw new IOException(this + " negative reply back from FTP server cmd: " + cmd + " reply:" + result + ": " + client.getReplyString() + " for " + flowFile);
            }
        }
    }
}
 
开发者ID:clickha,项目名称:nifi-tools,代码行数:19,代码来源:FTPTransferV2.java

示例3: makeRemoteDir

import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
protected void makeRemoteDir(FTPClient ftp, String dir)
        throws IOException {
    String workingDirectory = ftp.printWorkingDirectory();
    if (dir.indexOf("/") == 0) {
        ftp.changeWorkingDirectory("/");
    }
    String subdir;
    StringTokenizer st = new StringTokenizer(dir, "/");
    while (st.hasMoreTokens()) {
        subdir = st.nextToken();
        if (!(ftp.changeWorkingDirectory(subdir))) {
            if (!(ftp.makeDirectory(subdir))) {
                int rc = ftp.getReplyCode();
                if (rc != 550 && rc != 553 && rc != 521) {
                    throw new IOException("could not create directory: " + ftp.getReplyString());
                }
            } else {
                ftp.changeWorkingDirectory(subdir);
            }
        }
    }
    if (workingDirectory != null) {
        ftp.changeWorkingDirectory(workingDirectory);
    }
}
 
开发者ID:numsg,项目名称:spring-boot-seed,代码行数:26,代码来源:FtpHelper.java

示例4: getInputStream

import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
@Override
public InputStream getInputStream(final String remoteFileName, final FlowFile flowFile) throws IOException {
    final FTPClient client = getClient(null);
    InputStream in = client.retrieveFileStream(remoteFileName);
    if (in == null) {
        throw new IOException(client.getReplyString());
    }
    return in;
}
 
开发者ID:clickha,项目名称:nifi-tools,代码行数:10,代码来源:FTPTransferV2.java

示例5: rename

import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
@Override
public void rename(final String source, final String target) throws IOException {
    final FTPClient client = getClient(null);
    final boolean renameSuccessful = client.rename(source, target);
    if (!renameSuccessful) {
        throw new IOException("Failed to rename temporary file " + source + " to " + target + " due to: " + client.getReplyString());
    }
}
 
开发者ID:clickha,项目名称:nifi-tools,代码行数:9,代码来源:FTPTransferV2.java

示例6: deleteFile

import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
@Override
public void deleteFile(final String path, final String remoteFileName) throws IOException {
    final FTPClient client = getClient(null);
    if (path != null) {
        setWorkingDirectory(path);
    }
    if (!client.deleteFile(remoteFileName)) {
        throw new IOException("Failed to remove file " + remoteFileName + " due to " + client.getReplyString());
    }
}
 
开发者ID:clickha,项目名称:nifi-tools,代码行数:11,代码来源:FTPTransferV2.java

示例7: deleteDirectory

import org.apache.commons.net.ftp.FTPClient; //导入方法依赖的package包/类
@Override
public void deleteDirectory(final String remoteDirectoryName) throws IOException {
    final FTPClient client = getClient(null);
    final boolean success = client.removeDirectory(remoteDirectoryName);
    if (!success) {
        throw new IOException("Failed to remove directory " + remoteDirectoryName + " due to " + client.getReplyString());
    }
}
 
开发者ID:clickha,项目名称:nifi-tools,代码行数:9,代码来源:FTPTransferV2.java


注:本文中的org.apache.commons.net.ftp.FTPClient.getReplyString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。