package ru.agolovin;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author agolovin (agolovin@list.ru)
 * @version $Id$
 * @since 0.1
 */

public class ParallelSearch {

    private List<String> result = new CopyOnWriteArrayList<>();

    public void parallelSearch(String root, String text, List<String> exts) {
        File[] files = new File(root).listFiles();

    }

    private void searchTextInFile(final String text, final List<String> fileList) {
        for (String element : fileList) {
            if (element != null) {
                try {
                    byte[] bytes = Files.readAllBytes(Paths.get(element));
                    String str = new String(bytes);
                    if (str.contains(text)) {
                        this.result.add(element);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}

@@ -365,24 +365,92 @@
 yList%3C%3E();%0A%0A
+    private List%3CString%3E listFiles = new CopyOnWriteArrayList%3C%3E();%0A%0A
     public v
@@ -510,17 +510,16 @@
 ing%3E ext
-s
 ) %7B%0A    
@@ -573,16 +573,317 @@
 %0A    %7D%0A%0A
+    private void searchInDirectories(File file) %7B%0A        for (final File element : file.listFiles()) %7B%0A            if (element.isDirectory()) %7B%0A                searchInDirectories(element);%0A            %7D else %7B%0A                listFiles.add(element.getAbsolutePath());%0A            %7D%0A        %7D%0A    %7D%0A%0A
     priv

add task4 in part3 chapter7 package2