Returning array from recursive method

Dreni :

Hello i hope you are all good. I have this method i want to look recursively on a folder to count files and files that accept the condition and i want to return them as a array. I am having trouble on count+=countThem(file); , how can i fix it that that it can increase boll variables (count for files) and (countkusht for files that accept the condition)

  public int[] countThem(File f,String parameter) throws IOException {
            int count = 0;
            int countkusht = 0;
            File[] files = f.listFiles();
            for (File file : files) {
                   if(file.isDirectory()) {
                //->   **count+=countThem(file);**
                       }
                   else if(!file.isDirectory()) {
                                count++;
                       fr = new FileReader(file);
                       br = new BufferedReader(fr);

                       String line = null;

                       while((line = br.readLine())!=null) {
                            if(line.contains(parameter)) {
                                 countkusht++;
                            }
                       }       
                   }
            }

            return new int[] {count,countkusht};

        }
ControlAltDel :

You need to index the array results of countThem

               if(file.isDirectory()) {
                 int[] ct = countThem(file, parameter);
                 count+=ct[0]
                 countkusht+=ct[1];
               }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=26995&siteId=1