input string problem
<pre><code>System.out.println("Please enter the required word  :");
    Scanner scan2 = new Scanner(System.in);
    String word2 = scan2.nextLine();
    String[] array2 = word2.split(" ");

    for (int b = 0; b &lt; array2.length; b++) {
        int numofDoc = 0;

        for (int i = 0; i &lt; filename; i++) {

            try {

                BufferedReader in = new BufferedReader(new FileReader(
                        "C:\\Users\\user\\fypworkspace\\TextRenderer\\abc"
                                + i + ".txt"));

                int matchedWord = 0;

                Scanner s2 = new Scanner(in);

                {

                    while (s2.hasNext()) {
                        if (s2.next().equals(word2))
                            matchedWord++;
                    }

                }
                if (matchedWord &gt; 0)
                    numofDoc++;

            } catch (IOException e) {
                System.out.println("File not found.");
            }

        }
        System.out.println("This file contain the term  " + numofDoc);
    }
}
</code></pre>

<p>}</p>

<p>this is my code for calculating number of documents containing a specific term. For example :
assume i have 10 million text file and string COW appears in one thousand of these. I am looking for the total one thousand documents containing the COW string. </p>

<p>My program currently only can process one string input. </p>

<p>The output of my program is :</p>

<p>COW</p>

<p>The files containing this term is 1000. </p>

<p>The problem i facing now is when i input 3 strings, It cannot process 3 strings. For example :</p>

<p>COW IS GOOD</p>

<p>The files containing this term is 0.</p>

<p>The files containing this term is 0.</p>

<p>The files containing this term is 0. </p>

<p>I have been trying whole day but i cant see where is my mistake. Mind pointing my mistakes ? </p>
