title: Words frequency in percentage java
body: <p>I have to make a program that does the words frequency from a linkedlist and outputs the result like this : 
  word, number of occurrences, frequency in percentage</p>
  
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.*;
  
  public class Link {
  
      public static void main(String args[]) {
  
      long start = System.currentTimeMillis();
  
      LinkedList&lt;String&gt; list = new LinkedList&lt;String&gt;();
  
      File file = new File("words.txt");
  
      try {
  
          Scanner sc = new Scanner(file);
  
          String words;
  
          while (sc.hasNext()) {
              words = sc.next();
              words = words.replaceAll("[^a-zA-Z0-9]", "");
              words = words.toLowerCase();
              words = words.trim();
              list.add(words);
          }
  
          sc.close();
  
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      }
  
      Map&lt;String, Integer&gt; frequency = new TreeMap&lt;String, Integer&gt;();
  
      for (String count : list) {
          if (frequency.containsKey(count)) {
              frequency.put(count, frequency.get(count) + 1);
          } else {
              frequency.put(count, 1);
          }
      }
  
      System.out.println(frequency);
  
      long end = System.currentTimeMillis();
  
      System.out.println("\n" + "Duration: " + (end - start) + " ms");
      }
  }
  </code></pre>
  
  <p>Output : {a=1, ab=3, abbc=1, asd=2, xyz=1}</p>
  
  <p>What I don't know is how to do the frequency in percentage and ignore the words shorter than 2 caracters. For example "a=1" should be ignored.</p>
  
  <p>Thanks in advance.</p>