統計檔案數目
public class FileTypeCount {
int white = 0;
int other = 0;
LinkedList<String> whiteFileList = new LinkedList<>();
LinkedList<String> otherFileList = new LinkedList<>();
String[] whiteList = {"java", "jsp"};
@Test
public void scanFileType() {
String path = "C:\\Users\\beix\\Desktop\\yk";
recursionScan(path);
System.out.println(Arrays.toString(whiteList) + " count:" + white);
System.out.println("other file count:" + other);
}
public void recursionScan(String basePath) {
List<String> whiteArray = Arrays.asList(whiteList);
File file = new File(basePath);
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files != null) {
for (File f : files) {
if (!f.isDirectory()) {
String fileName = f.getName();
String fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
if (whiteArray.contains(fileType.toLowerCase())) {
whiteFileList.add(f.getAbsolutePath());
white++;
} else {
otherFileList.add(f.getAbsolutePath());
other++;
}
} else {
recursionScan(f.getAbsolutePath());
}
}
}
}
}
}
相關文章
- Android掃描檔案並統計各類檔案數目Android
- 統計檔案數目(不包括隱藏檔案/資料夾)
- 【shell程式設計】目錄檔案計數程式設計
- linux 快速計算檔案數和目錄數 (轉)Linux
- 統計檔案的行數
- 如何統計 Linux 中檔案和資料夾/目錄的數量Linux
- Git統計檔案的行數Git
- linux 統計當前目錄下檔案或者資料夾的數量Linux
- 統計檔案中單詞個數
- Linux檔案系統-目錄和檔案管理Linux
- Linux檔案系統、目錄Linux
- 【Linux】檔案系統目錄Linux
- java 統計大文字檔案的行數Java
- Linux 檔案系統的目錄Linux
- ls命令統計檔案數量不準確
- 統計檔案中出現的單詞次數
- 目錄結構檢視及目錄下各個檔案的大小的統計
- linux統計檔案個數及程式碼總行數Linux
- Linux下如何對目錄中的檔案進行統計Linux
- Linux檔案系統目錄結構Linux
- 沒有目錄建目錄,沒有檔案建檔案
- PHP+Mysql統計檔案下載次數例項PHPMySql
- 統計資料夾檔案數量的sh指令碼指令碼
- Linux Shell統計每秒鐘內檔案增加行數Linux
- 【Shell】統計檔案裡面特定字串出現次數字串
- 統計session 開啟的遊標數目Session
- Linux 檔案系統的目錄結構Linux
- Linux系統的目錄及重要檔案Linux
- Windows 快速統計檔案列表中檔案大小Windows
- 解析Linux系統根檔案系統的目錄樹Linux
- 多執行緒統計多個檔案的單詞數目---C++0x多執行緒使用示例執行緒C++
- EXT4檔案系統學習(15)VFS之VFS 檔案/目錄物件物件
- CentOS系統下/tmp目錄臨時檔案清理CentOS
- 使用SSHFS檔案系統遠端掛載目錄
- lc2953 統計完全子字串的數目字串
- 18、檔案與目錄
- 清理bdump目錄檔案
- 活動目錄域:新增計算機與檔案共享計算機