Displaying top 10 most occuring words in a file in descending order
<p>i am trying to make the code more  neat and efficient. iam trying to implement zamzela's[u will find one of the answers down]  method. iam having trouble implementing the comparator </p>

<p>public class WordCountExample {</p>

<pre><code>public static void main(String[] args) throws IOException {

    Set&lt;WordCount&gt; wordcount = new HashSet&lt;WordCount&gt;();

    File file = new File("c:\\test\\input1.txt");    //path to the file

    String str = FileUtils.readFileToString(file);   // converts a file into a string


    String[] words = str.split("\\s+");     // split the line on whitespace,
                                            // would return an array of words

    for (String s : words) {

        wordcount.add(new WordCount(s));

        WordCount.incCount();

    }

         /*here WordCount is the name of comparator class*/

          Collections.sort(wordcount,new WordCount());   //getting a error here 


    for (WordCount w : wordcount) {

        System.out.println(w.getValue() + " " + w.getCount());
    }

}
</code></pre>

<p>}</p>
