本文整理汇总了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));
}
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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());
}
}