类everything java源码

https://download.csdn.net/download/r77683962/10477640

当前实现的功能:

1、多字符串搜索;



2、支持正则表达式搜索;


搜索相关的代码:

public void proc(String inputStr)
{
    String[] strings = inputStr.split(" ");
    for (String string : strings)
           System.out.println(string);

   Object[][] rowData=new Object[ListAllFiles.allFile.size()][Strings.tableHead.length];
   int k=0;
       List<FileInfo>  rowData1=ListAllFiles.allFile;
       List<FileInfo>  rowData2 = new ArrayList<>();
   for (int j = 0; j < strings.length; j++)
       {
           k = 0;
           System.out.println("rowData1 size: "+rowData1.size());
           for (int i = 0; i < rowData1.size(); i++)
           {
               FileInfo fi = rowData1.get(i);
               if(strings[j].contains("["))
               {
                   if (Pattern.compile(strings[j]).matcher(fi.fileName).find())
                   {
                       if(j == strings.length -1)
                       {
                           rowData[k][0] = i + 1;
                           rowData[k][1] = fi.fileName;
                           rowData[k][2] = fi.filePath;
                           rowData[k][3] = fi.fileSize;
                           rowData[k][4] = fi.lastModifyTime;
                           k++;
                       }
                       rowData2.add(fi);
                   }
               }
               else if (fi.fileName.indexOf(strings[j]) != -1 )
               {
                   if(j == strings.length -1)
                   {
                       rowData[k][0] = i + 1;
                       rowData[k][1] = fi.fileName;
                       rowData[k][2] = fi.filePath;
                       rowData[k][3] = fi.fileSize;
                       rowData[k][4] = fi.lastModifyTime;
                       k++;
                   }
                   rowData2.add(fi);
                   System.out.println("rowData2 size: "+rowData2.size());
               }
           }
           rowData1 = new ArrayList<>(rowData2);
           rowData2.clear();
       }
       Object[][] result = new Object[k][Strings.tableHead.length];
       for( int i = 0; i < k; i++)
       {
           result[i][0] = rowData1.get(i).fileId;
           result[i][1] = rowData1.get(i).fileName;
           result[i][2] = rowData1.get(i).filePath;
           result[i][3] = rowData1.get(i).fileSize;
           result[i][4] = rowData1.get(i).lastModifyTime;
       }
       esb.jlst.setText(k + " items was found.");
       dtm.setDataVector(result, Strings.tableHead);
}

不支持的功能:

1、不能按目录搜索;

2、文件删除、新增、修改不能更新,这块可以自已实现;


原理:

1、将C/D/E/**盘所有文件和目录 读入到内存;

2、根据文件名查找;



阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页