reading more than one file
making another attempt because the other thread got long and confusing.
hi everyone, is reading a series of files (presenting the result for each file separately) more difficult than reading one? i have this code that can open a file and find three-word-combinations in it. what i would like to do is to go through 48 different files, all with very different names.
this code works for opening one file:publicstaticvoid main(String... args)throws Exception{
findIdioms(new File("Nytt.java"));
}
publicstaticvoid findIdioms(File file)throws Exception{
Scanner sc =new Scanner(file);
Pattern p = Pattern.compile("\\b(\\w+)\\s+(?=(\\w+)\\s+(\\w+)\\b)");
i have one file where i'll store the 48 files but if i could make it work by adding the files to the source program, that will be as good as calling the other file. what happens with the code above is that it opens "Nytt" but then reads the text in "Nytt" rather than opening the files it stores.
Nytt:
publicclass Nytt{
publicstaticvoid main(String[] args)throws Exception{
File[] corpus ={
new File("Test.txt"),
new File("Hej.txt")
};//here is where i'll add the other 47 files
for(int i = 0; i < corpus.length; i++){
GetStrings.findIdioms(corpus[i]);
}}}
does anyone know what i could add for it to start reading the files within "Nytt" instead of reading the code itself?
thank you in advance!

