In this code, we read data from a file named input.txt and count the frequency of each word using a HashMap. Then, we create a priority queue of Map.Entry objects, where the entries are sorted by decreasing value (i.e., frequency count). Finally, we print the top 5 most frequently occurring elements from the priority queue.
Note that this code assumes that words in the input file are separated by whitespace (i.e., spaces, tabs, or newlines). If your input file uses a different delimiter, you'll need to adjust the split() method accordingly.