Hi every one, this is my first post here!
I'm using GATE toolkit for information retrieval and text analysis, but i really need java for some parts.
I have managed to find a specific word in one text file, but i need to look for a specific word, in multiple text files. all of the files are ".txt" and they are in the same folder but each of them with different names. I have written the following code: but i receive an error that i don't know how to solve:
and this is the error that i get:
java.lang.NoSuc hMethodError: main
Exception in thread "main"
I would appreciate any helps and comments.
Maral
I'm using GATE toolkit for information retrieval and text analysis, but i really need java for some parts.
I have managed to find a specific word in one text file, but i need to look for a specific word, in multiple text files. all of the files are ".txt" and they are in the same folder but each of them with different names. I have written the following code: but i receive an error that i don't know how to solve:
Code:
import java.io.*;
import java.util.Scanner;
public class Find {
public static void main(String s) throws IOException {
int count =0;
String srcDir = s;
File folder = new File(srcDir);
File[] listOfFiles = folder.listFiles();
if (listOfFiles.length > 0) {
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
Scanner a = null;
a = new Scanner(new BufferedReader(new FileReader(srcDir + listOfFiles[i].getName())));
while (a.hasNext()){
String words = a.next();
if (words.equals("good")){
count++;
}
}
System.out.println("the total is:" + count);
}
}
}
}
}
java.lang.NoSuc hMethodError: main
Exception in thread "main"
I would appreciate any helps and comments.
Maral
Comment