當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。