程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> rename-apache FTPClient FTP如何實現文件移動?

rename-apache FTPClient FTP如何實現文件移動?

編輯:編程綜合問答
apache FTPClient FTP如何實現文件移動?

如題:
現在的情況是,我需要在FTP服務器上做這樣的操作:A文件夾移動到 B文件夾的子目錄..

看了網上說的用rename移動,根本不行,有經驗的大哥大姐們,支個招..

最佳回答:


問題已解決: 感謝 "不是阿爾伯特" 的指點..


private static String downLoadPath = "/主文件/"; 

String tempStr = fNames[i];
String simpleName = tempStr.substring(0,tempStr.lastIndexOf("."));

String movePath = "";
 if(typeCode.equals("0")){
               movePath = FTP_ORDER;  
 }else if(typeCode.equals("1")){
               movePath = FTP_TAXBILL;  
}else if(typeCode.equals("2")){
               movePath = FTP_WAYBILL;  
}else if(typeCode.equals("3")){
               movePath = FTP_GOODS;  
}

String oldName = downLoadPath+simpleName+".xml";
String newName = movePath+simpleName+"2a.xml";

logger.info(oldName);
logger.info(newName);

boolean bools = ftp.changeWorkingDirectory(downLoadPath);

logger.info(bools);

// boolean bool = ftp.rename("a.txt","b");
int RNFR = ftp.sendCommand(FTPCmd.RNFR,oldName);
int RANTO = ftp.sendCommand(FTPCmd.RNTO,newName);

logger.info(RNFR +"\t"+ RANTO);

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved