Java统计文件数量
package com.vfsd;
import java.io.File;
import java.io.IOException;
/*******************************************************************************************************
* Copyright: vc1.0 2018. All rights reserved.
* The whole package including this class is licensed under
*
* @ClassName:
* @Directory:
* @author: luozhubang
* @version: v1.0.0
* @date:
* @Description:
* 1、
* 2、
* @Others: 暂无说明
* @Modification History:
* 1、
* Date:
* Author:
* Modification:
*
* 2、
* Date:
* Author:
* Modification:
*
* @Statement: If you are using the package or parts of it in any commercial way, a commercial license is required.
* Visit http://www.bim-times.com for more information.
*
*********************************************************************************************************/
public class CountFileNum {
private static int count1 = 0;
public static void main(String[] args) throws IOException{
String dir1="E:\\20190418_relationdata4\\";
listFiles(dir1);
}
public static void listFiles(String filePath) throws IOException{
File dirFile = new File(filePath);
if(dirFile.isDirectory()) {
File[] files1 = dirFile.listFiles();
for(int i=0;i
countNum(files1[i].getPath());
System.out.println("count:"+count1+" "+files1[i].getName());
count1=0;
}
}
}
public static void countNum(String filePath) throws IOException{
File dirFile = new File(filePath);
if(dirFile.isDirectory()) {
File[] files1 = dirFile.listFiles();
for(int i=0;i
if(files1[i].getName().endsWith("02.txt")) {
count1++;
}
}
}
}
}
标签:文件,Java,String,listFiles,File,Modification,dirFile,public,统计
来源: https://www.cnblogs.com/herd/p/11784000.html