zoukankan      html  css  js  c++  java
  • Java

    package com.jyc.autoscanfile;


    import java.io.File;
    import java.util.ArrayList;
    import java.util.List;

    import com.atlife.callout.commons.autoRunThread.runImp.AutoRun;
    import com.atlife.callout.ruleImplement.dto.domain.Cc_action_ruleimplementDto;
    import com.sinosoft.sysframework.reference.DBManager;

    public class AutoScanFile implements AutoRun {

    private AutoScanFile autoScanFile;
    private DBManager dbManager;
    @Override
    public String run(DBManager dbManager,
    Cc_action_ruleimplementDto ccActionRuleimplementDto) {
    try {
    //System.out.println("running----------");
    scanFile(dbManager);
    //System.out.println("running-----2222-----");
    return "success";
    } catch (Exception e) {
    // TODO 自动生成 catch 块
    //e.printStackTrace();
    return "failure";
    }
    }

    //文件扫描
    private void scanFile(DBManager dbManager) {

    List<File> file = autoScanFile.getFiles(new File("F:\Program Files (x86)\test"),"MD5");
    for (File ff : file) {
    System.out.println(ff.getPath());
    System.out.println(ff.getName());
    }
    }



    public List<File> getFiles(File fileDir, String fileType) {
    List<File> lfile = new ArrayList<File>();
    File[] fs = fileDir.listFiles();
    for (File f : fs) {
    if (f.isFile()) {
    if (fileType
    .equals(f.getName().substring(
    f.getName().lastIndexOf(".") + 1,
    f.getName().length())))
    lfile.add(f);
    } else {
    List<File> ftemps = getFiles(f,fileType);
    lfile.addAll(ftemps);
    }
    }
    return lfile;
    }


    public static void main(String[] args) {
    /*AutoScanFile imp = new AutoScanFile();
    DBManager dbManager = new JdbcManager();
    try {
    dbManager.open("platformDataSource");
    imp.run(dbManager, null);
    } catch (Exception ex) {
    ex.printStackTrace();
    } finally {
    try {
    dbManager.close();
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }*/
    }

    }

  • 相关阅读:
    Linux下wget下载软件小技巧以及安装jdk、tomcat与ftp服务器
    C++计算二叉树的节点数和高度
    转:POST 400 Bad Request The request sent by the client was syntactically incorrect
    SSM项目spring配置文件详细步骤(分门别类、灵巧记忆)
    IntelliJ IDEA里找不到javax.servlet的jar包
    51nod 1533 && CF538F
    51nod 1189
    51nod 1225
    51nod 1040
    51nod 1610
  • 原文地址:https://www.cnblogs.com/qq3245792286/p/6165684.html
Copyright © 2011-2022 走看看