title: How to get the size of String java.util.Map.Entry.getKey() in java?
body: <p>I tried some options but I could not get my required output.</p>
  
  <p>The question is how to get the size of <code>m.getKey()</code></p>
  
  <p>I tried <code>m.getKey().length</code> ,<code>m.getKey().size</code> but I could not find.</p>
  
  <pre><code>System.out.print("\n duplicate words: ");
  for(Map.Entry&lt;String, Integer&gt; m:  map.entrySet()){
  if(m.getValue()&gt;toStringArray.length-1)
  );
  System.out.print(m.getKey() + " ");
  }
  </code></pre>
  
  <p>The output is </p>
  
  <blockquote>
    <p>( HI THIS IS MY OUTPUT)</p>
  </blockquote>
  
  <p>The output which I needed is </p>
  
  <blockquote>
    <p>(5) //HI THIS IS MY OUTPUT total count is 5</p>
  </blockquote>
  
  <p>Suggestions are Welcomed.</p>
  
  <p>I am a beginner to java </p>
  
  <p>Here is my Full code</p>
  
  <pre><code>import java.io.File;
  import java.io.FileInputStream;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Scanner;
  import org.apache.commons.io.IOUtils;
  
  
  public class testduplicatewordnew {
  public static void main(String[] args) throws Exception {
  
  /* Reading text content from file    */
   FileInputStream fisTargetFile = new FileInputStream(new File("E:\\testfolder\\மிரளச் செய்யும் மிலரபாவின் கதை!  Isha Tamil Blog 15.txt"));
  
      String targetFileStr = IOUtils.toString(fisTargetFile, "UTF-8");
  
   String []toStringArray = targetFileStr.split(" ");
  
  
   HashMap&lt;String , Integer&gt; map = analyzeWords("Analyzing contents ", toStringArray);
  
  
  
   System.out.print("\nduplicate words: ");
   for(Map.Entry&lt;String, Integer&gt; m:  map.entrySet()){
   if(m.getValue()&gt;toStringArray.length-1)
  // System.out.print(m.getKey() + "-" + m.getValue()/(toStringArray.length-1) + " ");
    System.out.print(m.getKey()+ " ");
   // System.out.println(map.keySet().size());
  // System.out.println(m.getValue());
  
  
  }
   System.out.println("\n");
   }
  
   private static HashMap&lt;String, Integer&gt; analyzeWords(String command, String []toStringArray ){
  System.out.println(command);  
  
  HashMap&lt;String, Integer&gt; unik = new HashMap&lt;String, Integer&gt;();  
  
  int i =0;
  while(i&lt;toStringArray.length){ unik.put(toStringArray[i++], 0);}
  
   for(i = 0; i&lt; toStringArray.length; i++){   
   for(int j = 0; j&lt; toStringArray.length; j++ ){
   if( (toStringArray[i] != toStringArray[j]) &amp;&amp; (i != j))
    unik.put(toStringArray[i],(int)unik.get(toStringArray[i]) +1);
   }
   }// oef outter for loop
  
  
   return unik;
   }// eof analyzeWords method
  
   /* method to read file content.
    * returns the contents of text file as a string */
   private static String fileNameReader(String fileName) throws FileNotFoundException{
  System.out.println("\nReading " +fileName+ " file");
  String generateString = "";
  try{   
   File file = new File(fileName);
   Scanner scanner = new Scanner(file);
  
   generateString = scanner.nextLine();
   while (scanner.hasNextLine()) {
        generateString = generateString + "\n" + scanner.nextLine();
   }scanner.close();
   System.out.println("\nInitial content");
   System.out.println(generateString);
  }catch(IOException e){
   System.out.println("\nError occured while reading file...");
   }
  return generateString;
   }// eof fileNameReader method
  }
  </code></pre>