package ru.job4j.inputouput;

import ru.job4j.simpletree.Node;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class Search {

   private List<String> list = new ArrayList<>();

   public void add(File dir, List<String> exts) {
       for (int i = 0; i < dir.listFiles().length; i++) {
           File file = new File(dir.listFiles()[i].getPath());
           String path = file.getName().toString();
           if (!file.isDirectory()) {
               for (int j = 0; j < exts.size(); j++) {
                   if (path.contains(exts.get(j))) {
                       list.add(path);
                   }
               }
           } else {
               add(file, exts);
           }
       }
   }

   public static void main(String[] args) {
       File dir1 = new File(System.getProperty("java.io.tmpdir"));
       List<String> exts = new ArrayList<>();
       exts.add(".txt");
       Search search = new Search();
       search.add(dir1, exts);
       for (int i = 0; i < search.list.size(); i++) {
           System.out.println(search.list.get(i));
       }

   }

}

@@ -131,168 +131,313 @@
 til.
-ArrayList;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0Aimport java.util.Queue;%0A%0Apublic class Search %7B%0A%0A   private List%3CString%3E list = new ArrayList%3C%3E();
+*;%0A%0Apublic class Search %7B%0A%0A   private List%3CString%3E list = new ArrayList%3C%3E();%0A%0A   public boolean isExts(List%3CString%3E exts, String path) %7B%0A       for (int i = 0; i %3C exts.size(); i++) %7B%0A           if (path.contains(exts.get(i))) %7B%0A                return true;%0A           %7D%0A       %7D%0A       return false;%0A   %7D
 %0A%0A  
@@ -714,105 +714,34 @@
     
-for (int j = 0; j %3C exts.size(); j++) %7B%0A                   if (path.contains(exts.get(j
+if (isExts(exts, path
 ))
-)
  %7B%0A
-    
     
@@ -775,29 +775,8 @@
 h);%0A
-                   %7D%0A
     
@@ -1232,17 +1232,16 @@
       %7D%0A
-%0A
    %7D%0A%0A%7D%0A

task #106929