Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class classWork19042021 {
- public static void main(String[] args) {
- HashMap <String, Integer> WordsCounter = new HashMap<>();
- Scanner wordsFile = new Scanner(new File(""));
- int counter;
- while(wordsFile.hasNextLine()){
- counter = 0;
- String searchedWord = wordsFile.nextLine().toLowerCase();
- WordsCounter.put(searchedWord, counter);
- Scanner sampleFile = new Scanner(newFile(""));
- while(sampleFile.hasNext()){
- String searchedText = sampleFile.next().toLowerCase();
- if(searchedText.contains(searchedWord)){
- counter++;
- }
- }
- WordsCounter.put(searchedWord, counter);
- sampleFile.close();
- }
- wordsFile.close();
- System.out.println("Namereni povtoreniq: ");
- System.out.println(WordsCounter);
- ///DA SE DOPISHE KODA ZA DA GO ZAPISVA V RESULT I DA GO OTPECHATI
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment