I've written the code below and from what I can guess it should execute correctly but it doesn't and I'm hitting my head against a wall. What I'm trying to do after finding the objects to be added to the temp vector list is to loop through the vector list take each file name and count the number of occurrences of a word. I can get both pieces of code to work seperately but when I put them together the code stops executing after the temp vector list has been filled. Can anyone see from my code below what is stopping the rest of the code from executing?
EDITTED CODE >> I've changed a few things around in the code to format correctly and to remove the duplication but now nothing outputs to the screen. I'm sure it's something simple but I just don't seem to be able to see it.
for(int m = 0; m < temp.size() && occurCount < wordCount;m++)
{
File aFile2 = new File(temp.elementAt(m));
FileReader aFileReader = new FileReader(aFile2);
BufferedReader aBufferReader = new BufferedReader(aFileReader);
while((line = aBufferReader.readLine()) != null && occurCount < wordCount)
{
words = line.toLowerCase().split(" ");
if (line == null)
break;
else
{
for(int k = 0; k < words.length && occurCount < wordCount;k++)
{
if(words[k].matches(wordToSearch))
{
occur++;
q.add(words[k]);
}
else if(words[k].matches(pattern))
{
System.out.println(words[k]);
if(temp.contains(words[k]))
System.out.println("Word already in list");
else
{
temp.add(words[k]);
}
}
}
}
lineFile = "";
}
occurCount = occur;
occur = 0;
aBufferReader.close();
searched.add(temp.elementAt(m));
occurCount2 += occurCount;
//occurCount += occurCount;
System.out.println(occurCount);
System.out.println(q);
System.out.println(temp);
System.out.println(searched);