title: Converting emoji to HTML Decimal Code or Unicode Hexadecimal Code in java
body: <p>I am trying to convert text file with emoji content to the file with emoji's html code or Hex code using Java.
  example :</p>
  
  <p>I/p : <code>&amp;lt;div id="thread" style="white-space: pre-wrap;"&amp;gt;&amp;lt;div&amp;gt;⚽️</code></p>
  
  <p>Expected o/p :<code>&amp;lt;div id="thread" style="white-space: pre-wrap;"&amp;gt;&amp;lt;div&amp;gt;&amp;#128512;&amp;#128512;&amp;#128515;&amp;#127822;&amp;#127823;&amp;#9917;&amp;#65039;&amp;#127936;</code></p>
  
  <p>In above out put <code>''</code> should get changed to the corresponding html entity code<code>'&amp; # 128512;'</code></p>
  
  <p>Detail of Html entity code and hex code is given here :
  <a href="http://character-code.com/emoticons-html-codes.php" rel="nofollow noreferrer">http://character-code.com/emoticons-html-codes.php</a></p>
  
  <p>Sample code that i tried is below :</p>
  
  <pre><code>try {
              File file = new File("/inFile.txt");
              str = FileUtils.readFileToString(file, "ISO-8859-1");
              System.out.println(new String(str.getBytes(), "UTF-8"));
              String results = StringEscapeUtils.escapeHtml4(str);
              System.out.println(results);
          } catch (IOException e) {
              e.printStackTrace();
          }
  </code></pre>