반복적 방법에서 복귀 어레이

드렌 (Dren) :

안녕하세요 난 당신이 모든 좋은 바랍니다. 난 내가 파일과 조건을 받아 들일 파일을 계산하는 폴더에 재귀 적으로보고 싶은이 방법이 있고 나는 배열로를 반환합니다. 나는 계산에 문제가 있어요 + = countThem (파일); , 어떻게하면 (조건을 받아 들일 파일 countkusht) 꼬투리 변수 (파일의 개수) 등을 증가시킬 수 있다는 것을 고칠 수

  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 :

당신은 인덱스에 countThem의 배열의 결과를 필요

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

추천

출처http://43.154.161.224:23101/article/api/json?id=27333&siteId=1