本文整理匯總了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());
}
}