Zeshin

classworkKrasi1904

Apr 19th, 2021
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. public class classWork19042021 {
  4.     public static void main(String[] args) {
  5.         HashMap <String, Integer> WordsCounter = new HashMap<>();
  6.         Scanner wordsFile = new Scanner(new File(""));
  7.         int counter;
  8.         while(wordsFile.hasNextLine()){
  9.             counter = 0;
  10.             String searchedWord = wordsFile.nextLine().toLowerCase();
  11.             WordsCounter.put(searchedWord, counter);
  12.             Scanner sampleFile = new Scanner(newFile(""));
  13.             while(sampleFile.hasNext()){
  14.                 String searchedText = sampleFile.next().toLowerCase();
  15.                 if(searchedText.contains(searchedWord)){
  16.                     counter++;
  17.                 }
  18.             }
  19.             WordsCounter.put(searchedWord, counter);
  20.             sampleFile.close();
  21.         }
  22.         wordsFile.close();
  23.         System.out.println("Namereni povtoreniq: ");
  24.         System.out.println(WordsCounter);
  25.         ///DA SE DOPISHE KODA ZA DA GO ZAPISVA V RESULT I DA GO OTPECHATI
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment