zoukankan      html  css  js  c++  java
  • Java统计文件数量

    Java统计文件数量

    package com.vfsd;
    
    import java.io.File;
    import java.io.IOException;
    
    /*******************************************************************************************************
     * Copyright: vc1.0 2018. All rights reserved.                    <br>
     * The whole package including this class is licensed under        <br>
     *                                                                 <br>
     * @ClassName:                                        <br>
     * @Directory:                                        <br>
     * @author:           luozhubang                                    <br>
     * @version:         v1.0.0                                        <br>
     * @date:                                                <br>
     * @Description:                                                 <br>
     *       1、                                        <br>
     *       2、                                        <br>
     * @Others: 暂无说明                                                <br>
     * @Modification History:                                        <br>
     *       1、                                            <br>
     *       Date:                              <br>
     *       Author:                                        <br>
     *       Modification:                                     <br>
     *                                                                 <br>
     *       2、                                                        <br>
     *       Date:                                                  <br>
     *       Author:                                                   <br>
     *       Modification:                                          <br>
     *       
     * @Statement: If you are using the package or parts of it in any commercial way, a commercial license is required. <br>
     *   Visit <a href='http://www.bim-times.com'>http://www.bim-times.com</a> for more information.<br>
     * 
    *********************************************************************************************************/
    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<files1.length;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<files1.length;i++) {
                    if(files1[i].getName().endsWith("02.txt")) {
                        count1++;
                    }
                }
                
            }
        }
    
    }
  • 相关阅读:
    myelipse与idea的javaweb项目创建
    入站规则和出站规则设置
    NAT技术基本原理与应用
    如何将sqlserver数据中的数据导出到服务器
    如何将SqlServer中表结构以及表数据全部导出
    国外服务器--新加坡服务器
    windows server2008 创建新用户 远程桌面连接 和 多用户登录问题
    程序员应该关注的国外IT网站
    IDEA创建普通java和web项目教程
    IIS Express 通过IP访问的方法和坑
  • 原文地址:https://www.cnblogs.com/herd/p/11784000.html
Copyright © 2011-2022 走看看