I am trying to count duplicating words in a file and I would like to write to the file my output
public static void main(String a[]){
MaxDuplicateWordCount mdc = new MaxDuplicateWordCount();
Map<String, Integer> wordMap = mdc.getWordCount("C:/Users/Arnoldas/Desktop/Hamletas.txt");
List<Entry<String, Integer>> list = mdc.sortByValue(wordMap);
for(Map.Entry<String, Integer> entry:list){
System.out.println(entry.getKey()+" ==== "+entry.getValue());
}
}
Output now looks like:
hamletui ==== 4
šmėkla ==== 2
jo ==== 2
hamletas ==== 1
danijos ==== 1
pagrindiniam ==== 1
mirusio ==== 1
princui ==== 1
herojui, ==== 1
apsireiškusi ==== 1
karalystės ==== 1
paveda ==== 1
parketas ==== 1
herojui ==== 1
žudikui ==== 1
neseniai ==== 1
omletas ==== 1
atkeršyti ==== 1
tėvo ==== 1
I would like to put this output to the file and it should look like:
| hamletui | šmėkla | jo | hamletas | danijos | pagrindiniam | ...
-------------------------------------------------------------------------------------
Hamletas.txt | 4 | 2 | 2 | 0 | 0 | 0 | ...
-------------------------------------------------------------------------------------
Other_file.txt | 0 | 0 | 6 | 3 | 4 | 1 | ...
Is it possible to do like that? Also I would like to get output and from others files. Have any ideas?