




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、文檔根源為:從網絡采集整理.word版本可編寫.支持.一個javaFTP的客戶端使用的了apache的commons-net實現批量下載,上傳,刪除等功能:import;import;import;import;import;import;import;import;import;import;import;publicclassFtpClientHandlerprivateFTPClientf=newFTPClient();privateStringhost=;privateStringusername=test;privateStringpassword=test;privateStrin
2、gr_workDirector=./;privateStringl_workDirector=./;privateStringconfig_file=./config/perties;privateStringremote_files=*;privateStringlocal_files=*;publicFtpClientHandler()throwsIOExceptionsuper();init();publicvoidinit()throwsIOException文檔根源為:從網絡采集整理.word版本可編寫.支持.FileInputStreamfis=newFileInputStream
3、(config_file);Propertiesconfig=newProperties();config.load(fis);host=config.getProperty(Boss_FTP_Url);username=config.getProperty(Username);password=config.getProperty(Password);r_workDirector=config.getProperty(Remote_workdirector);l_workDirector=config.getProperty(Local_workdirector);remote_files=
4、config.getProperty(Remote_download_files);local_files=config.getProperty(Local_upload_files);privatevoidconnection()throwsSocketException,IOExceptionf.connect(host);f.login(username,password);f.changeWorkingDirectory(r_workDirector);privatevoidclose()throwsIOExceptionif(f!=null)f.disconnect();public
5、voidDeleteFiles()throwsIOExceptionconnection();FTPListParseEngineengine=f.initiateListParsing(remote_files);FTPFilefiles=engine.getFiles();for(inti=0;i);f.dele(filesi.getName();文檔根源為:從網絡采集整理.word版本可編寫.支持.close();publicvoidDownloadFiles()throwsFileNotFoundException,IOExceptionconnection();FTPListPars
6、eEngineengine=f.initiateListParsing(remote_files);FTPFilefiles=engine.getFiles();for(inti=0;i);f.retrieveFile(filesi.getName(),newFileOutputStream(newFile(l_workDirector+filesi.getName();close();publicvoidStorFiles()throwsFileNotFoundException,IOExceptionconnection();Filefile=newFile(l_workDirector)
7、;/在此目錄中找文件BFSFileSearchsearch=newBFSFileSearch();ListfileList=search.scanFiles(file,local_files);for(inti=0;ifileList.size();i+)StringfileName=(String)fileList.get(i);f.storeFile(fileName,newFileInputStream(newFile(l_workDirector+fileName);close();文檔根源為:從網絡采集整理.word版本可編寫.支持.此中利用了深度搜尋體制來對*,?等通配符的支持:i
8、mport;import;import;import;publicclassBFSFileSearch/*paramfileName*String需要查找的文件,可含通配符如*.javaparambaseFileString欲查找的文件夾paramArrayList*fileList結果集paramcountint控制結果數目,為0,表示返回全部的般配的文件*/publicvoidscanFiles(Filebase,StringfileName,ListfileList,intcount)Queuequeue=newQueue();/實例化行列queue.put(base);/入隊while
9、(!queue.isEmpty()Filef=(File)queue.get();/if(f.exists()&f.isDirectory()出行列for(inti=0;i=count)return;fileList.add(filePath);/增添到結果集/*overwritemethodscanFilesparambaseparamfileNamereturn*/publicListscanFiles(Filebase,StringfileName)Queuequeue=newQueue();/實例化行列queue.put(base);/入隊ListfileList=newArrayLi
10、st();while(!queue.isEmpty()Filef=(File)queue.get();/出行列文檔根源為:從網絡采集整理.word版本可編寫.支持.if(f.exists()&f.isDirectory()Stringfiles=f.list();for(inti=0;ifiles.length;i+)Filef2=newFile(f,filesi);if(f2.isDirectory()/queue.put(f2);文件夾則進行列else/文件則進行般配StringfilePath=f2.getAbsolutePath();filePath=filePath.substrin
11、g(filePath.lastIndexOf(/)+1);/if(wildcardMatch(fileName,提取文件名filePath)/般配成功fileList.add(filePath);/增添到結果集returnfileList;publicbooleanwildcardMatch(Stringpattern,Stringstring)intstringLength=string.length();intstringIndex=0;for(intpatternIndex=0;patternIndexpattern.length();+patternIndex)charc=patter
12、n.charAt(patternIndex);if(c=*)while(stringIndexstringLength)returnfalse;elseif(stringIndex=stringLengthc!=string.charAt(stringIndex)returnfalse;+stringIndex;returnstringIndex=stringLength;classQueue/先進先出的行列privateVectorvector=newVector();publicvoidput(Objectobject)/vector.addElement(object);入隊publicObjectget()/出隊Objectobject=peek();if(object!=null)vector.removeElementAt(0);文檔根源為:從網絡采集整理
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 入戶維修調研報告范文
- 熱成型實驗報告范文
- 2025年度智慧城市建設合作協議解除合同書
- 二零二五年度網絡游戲押金轉讓與賬號安全保障協議
- 二零二五年度平面模特時尚雜志封面拍攝合同書
- 二零二五年度獵聘市場營銷人才委托協議
- 二零二五年度輪胎品牌授權與銷售代理合同
- 二零二五年度交通事故保險賠償協議書(含事故調查服務)
- 2025年度社區(qū)餐飲合伙經營與社區(qū)服務合同
- 二零二五年度農村土地流轉合同轉讓與生態(tài)保護協議
- 企業(yè)人力資源內部審核檢查表
- 《素描》課件-第一章 素描入門
- GB/T 42828.1-2023鹽堿地改良通用技術第1部分:鐵尾砂改良
- 工資條(標準模版)
- 第四講 搜索引擎檢索
- 法語的發(fā)音規(guī)則及法語單詞分類記憶
- 衛(wèi)生和微生物基礎知識培訓-
- ICU輪轉護士培訓計劃和手冊
- GB/T 9787-1988熱軋等邊角鋼尺寸、外形、重量及允許偏差
- GB/T 17614.1-2015工業(yè)過程控制系統(tǒng)用變送器第1部分:性能評定方法
- 財務工作督導檢查記錄表
評論
0/150
提交評論