前天正好要找一个本地文件, 就用java实现了, 全盘的本地文件搜索功能. 代码不依赖其它第三方jar, 连日志都用system.out了. 初学者可以了解下.
主程序: LocalFileSearcher.java
LocalFileSearcher searcher = new LocalFileSearcher();
searcher.doSearch("迅雷");
log如下:
Start search keyword: 迅雷
Start search all drivers!
success: E:\迅雷下载
success: F:\迅雷下载
success: C:\Users\Administrator\Desktop\迅雷.lnk
success: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\迅雷软件
success: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\迅雷软件\迅雷
success: C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\迅雷软件
success: C:\Users\Administrator\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\迅雷.lnk
success: C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Libraries\迅雷下载.library-ms
success: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\迅雷软件\迅雷\迅雷影音.lnk
success: C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\迅雷软件\迅雷
success: C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\迅雷软件
success: C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\迅雷软件\迅雷\迅雷影音.lnk
success: C:\Users\Administrator\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\迅雷.lnk
success: C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\迅雷软件\迅雷
success: C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\迅雷软件\迅雷\卸载迅雷.lnk
success: C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\迅雷软件\迅雷\迅雷.lnk
Search costs : 3861(ms)
File searched : 154848
Folder searched: 31463
Success match : 16
后续再更新完善
1