• 从多层级的目录文件中查找字符串


    从多层级的目录文件中查找指定的字符串

    package com.vfsd.core;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    
    public class StringFind {
        
        public static void main(String[] args) throws IOException
        {
            //File dir1 = new File("O:\OpenSceneGraph\OpenSceneGraph_3_6_install\");
            //File dir1 = new File("E:\OpenSceneGraph\OpenSceneGraph_3_4_install\");
            //File dir1 = new File("K:\Qt\Qt5.12.2\5.12.2\msvc2015_64\");
            //File dir1 = new File("E:\Geos\geos_3_5_install\");
            //File dir1 = new File("E:\GDAL\gdal212_install\");
            //File dir1 = new File("E:\CURL\curl_install\");
            //File dir1 = new File("E:\OpenSceneGraph\3rdParty\v140-x64\");
            //File dir1 = new File("E:\Opencv\opencv_3_4_6_install\");
            //File dir1 = new File("E:\boost_1_70_0\vc14-x64\");
            //File dir1 = new File("E:\IFCPlus");
            File dir1 = new File("E:\OpenFace\OpenFace-master2");
            //searchString("<iostream>",dir1);
            //searchString("<sstream>",dir1);
            //searchString("<fstream>",dir1);
            //searchString("<ostream>",dir1);
            searchString("fs::",dir1);
        }
        
        public static void searchString(String strFind,File dirParam) throws IOException
        {
            File []files1 = dirParam.listFiles();
            for(int k=0;k<files1.length;k++)
            {
                File fileIndex = files1[k];
                //System.out.println(fileIndex.getName());
                if(fileIndex.isDirectory())
                {
                    searchString(strFind,fileIndex);
                }else
                {
                    getFileContent(strFind,fileIndex);
                }
            }
        }
        
        public static void getFileContent(String strFind,File fileParam) throws IOException
        {
            try {
                FileReader fileReader1 = new FileReader(fileParam);
                BufferedReader bufferedReader1 = new BufferedReader(fileReader1);
                String lineStr1="";
                while((lineStr1=bufferedReader1.readLine())!=null)
                {
                    if(lineStr1.contains(strFind))
                    {
                        System.out.println(fileParam.getPath()+"					"+lineStr1);
                    }
                }
                bufferedReader1.close();
                fileReader1.close();
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
        }
    
    }

    输出:

    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalyserincludeFaceAnalyserParameters.h fs::path root;
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyser.cpp fs::path root = fs::path(model_loc).parent_path();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyser.cpp fs::path root = fs::path(au_model_location).parent_path();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp this->root = fs::path(arguments[0]).parent_path();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp fs::path config_path = fs::path(CONFIG_DIR);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp fs::path model_path = fs::path(this->model_location);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp if (fs::exists(model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp else if (fs::exists(root/model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp else if (fs::exists(config_path/model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp fs::path config_path = fs::path(CONFIG_DIR);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp fs::path model_path = fs::path(this->model_location);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp if (fs::exists(model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp else if (fs::exists(root / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp else if (fs::exists(config_path / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp fs::path config_path = fs::path(CONFIG_DIR);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp fs::path model_path = fs::path(this->model_location);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp if (fs::exists(model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp else if (fs::exists(root / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp else if (fs::exists(config_path / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp fs::path config_path = fs::path(CONFIG_DIR);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp fs::path model_path = fs::path(this->model_location);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp if (fs::exists(model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp else if (fs::exists(root / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalFaceAnalysersrcFaceAnalyserParameters.cpp else if (fs::exists(config_path / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcFaceDetectorMTCNN.cpp fs::path root = fs::path(location).parent_path();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorModel.cpp fs::path root = fs::path(clnf_location).parent_path();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorModel.cpp fs::path root = fs::path(main_location).parent_path();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorModel.cpp std::string root_loc = fs::path(main_location).parent_path().string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp fs::path root = fs::path(arguments[0]).parent_path();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp fs::path config_path = fs::path(CONFIG_DIR);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp fs::path model_path = fs::path(model_location);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp if (fs::exists(model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp else if (fs::exists(root/model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp else if (fs::exists(config_path/model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp model_path = fs::path(haar_face_detector_location);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp if (fs::exists(model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp else if (fs::exists(root / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp else if (fs::exists(config_path / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp model_path = fs::path(mtcnn_face_detector_location);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp if (fs::exists(model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp else if (fs::exists(root / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp else if (fs::exists(config_path / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp fs::path config_path = fs::path(CONFIG_DIR);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp fs::path model_path = fs::path(model_location);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp fs::path root_path = fs::path(root);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp if (fs::exists(model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp else if (fs::exists(root_path / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalLandmarkDetectorsrcLandmarkDetectorParameters.cpp else if (fs::exists(config_path / model_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcImageCapture.cpp std::string separator = std::string(1, fs::path::preferred_separator);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcImageCapture.cpp fs::path image_directory(directory);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcImageCapture.cpp std::vector<fs::path> file_in_directory;
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcImageCapture.cpp copy(fs::directory_iterator(image_directory), fs::directory_iterator(), back_inserter(file_in_directory));
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcImageCapture.cpp for (std::vector<fs::path>::const_iterator file_iterator(file_in_directory.begin()); file_iterator != file_in_directory.end(); ++file_iterator)
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcImageCapture.cpp fs::path current_file = *file_iterator;
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcImageCapture.cpp fs::path bbox_file = bbox_directory / current_file.filename().replace_extension("txt");
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcImageCapture.cpp if (fs::exists(bbox_file))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp if (!fs::exists(output_path))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp bool success = fs::create_directories(output_path);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp fs::path of_det_name(out_name);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp of_det_name = fs::path(record_root) / fs::path(out_name + "_of_details.txt");
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp if (!fs::path(input_filename_full).is_absolute())
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp input_filename_full = fs::canonical(input_filename_relative).string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp hog_filename = (fs::path(record_root) / hog_filename).string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp this->media_filename = (fs::path(record_root) / this->media_filename).string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp this->media_filename = (fs::path(record_root) / this->media_filename).string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp this->aligned_output_directory = (fs::path(record_root) / this->aligned_output_directory).string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp if (fs::is_directory(in_filename))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp out_name = fs::canonical(in_filename).filename().string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp out_name = fs::path(in_filename).filename().replace_extension("").string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp record_root = (fs::path(record_root) / fs::path(arguments[i + 1])).remove_filename().string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp out_name = fs::path(fs::path(arguments[i + 1])).replace_extension("").filename().string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp if (fs::is_directory(in_filename))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp out_name = fs::canonical(fs::path(in_filename)).filename().string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp out_name = fs::path(in_filename).filename().replace_extension("").string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp csv_filename = (fs::path(record_root) / csv_filename).string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcRecorderOpenFace.cpp std::string out_file = (fs::path(aligned_output_directory) / fs::path(std::string(name) + params.imageFormatAligned())).string();
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcSequenceCapture.cpp std::string separator = std::string(1, fs::path::preferred_separator);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcSequenceCapture.cpp fs::path image_directory(directory);
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcSequenceCapture.cpp if (!fs::exists(image_directory))
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcSequenceCapture.cpp std::vector<fs::path> file_in_directory;
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcSequenceCapture.cpp copy(fs::directory_iterator(image_directory), fs::directory_iterator(), back_inserter(file_in_directory));
    E:OpenFaceOpenFace-master2OpenFace-masterliblocalUtilitiessrcSequenceCapture.cpp for (std::vector<fs::path>::const_iterator file_iterator(file_in_directory.begin()); file_iterator != file_in_directory.end(); ++file_iterator)

  • 相关阅读:
    互联网实习笔记之shell笔记
    互联网实习笔记之30天总结
    记被论文排版虐的一天
    大论文排版技巧
    Matlab2014a使用VS2015混合编译
    腾讯云服务器创建swap空间
    使用vs2015开发linux:Ubuntu程序
    使用VS2015远程GDB调试
    nullptr、NULL、null和0
    《将博客搬至CSDN》
  • 原文地址:https://www.cnblogs.com/herd/p/11704675.html
Copyright © 2020-2023  润新知