right, so ive got this problem, basically, ive got a bunch of text files and i want to use the scanner to go through every single file, and seperate every single word from all the text files, i tried everythnig, and ive scoured this forum my code looks like this:
import java.io.*;
import java.util.Scanner;
public class test {
public static void main(String[] args) throws IOException {
Scanner scanner = null;
File dir = new File("C:/Documents and Settings/User/My Documents/corpus.txt"); // here i want to load not one but many files
try {
scanner = new Scanner(new BufferedReader(new FileReader(dir)));
while (scanner.hasNext()) {
System.out.println(scanner.next());
}
} finally {
if (scanner != null) {
scanner.close();
}
}
}
}
as you can see above there is the line where u load the single text file, but i wanna load in like 5 text files, help anyone?