Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1.  ///ZADANIE 3///
  2.             System.out.println("\n///ZADANIE 3///\n");
  3.             Map<String, String> artistRanking = new HashMap<>();
  4.             fr = new FileReader(FILENAME2);
  5.             br = new BufferedReader(fr);
  6.  
  7.             while ((sCurrentLine = br.readLine()) != null) {
  8.                 results = sCurrentLine.split("<SEP>");
  9.                 artistRanking.put(results[1], results[2]);
  10.             }
  11.  
  12.             Map<String, Integer> grupedartistRanking = new HashMap<>();
  13.             fr = new FileReader(FILENAME1);
  14.             br = new BufferedReader(fr);
  15.             while ((sCurrentLine = br.readLine()) != null) {
  16.                 results = sCurrentLine.split("<SEP>");
  17.                 String value =  artistRanking.get(results[1]);
  18.                 if(grupedartistRanking.get(value) == null){
  19.                     grupedartistRanking.put(value, 1);
  20.                 }else{
  21.                     int tempval = grupedartistRanking.get(value);
  22.                     tempval++;
  23.                     grupedartistRanking.put(value, tempval);
  24.                 }
  25.             }
  26.  
  27.             key = Collections.max(grupedartistRanking.entrySet(), Map.Entry.comparingByValue()).getKey();
  28.             System.out.println(key + " " + grupedartistRanking.get(key));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement