title: How to convert a string to a HashMap?
body: <p>I have a Java Property file and there is a <code>KEY</code> as <code>ORDER</code>. So I retrieve the <code>VALUE</code> of that <code>KEY</code> using the <code>getProperty()</code> method after loading the property file like below.:</p>
  
  <pre><code>String s = prop.getProperty("ORDER");
  </code></pre>
  
  <p>then</p>
  
  <pre><code>s ="SALES:0,SALE_PRODUCTS:1,EXPENSES:2,EXPENSES_ITEMS:3";
  </code></pre>
  
  <p>I need to create a HashMap from above string. <code>SALES,SALE_PRODUCTS,EXPENSES,EXPENSES_ITEMS</code> should be <code>KEY</code> of HashMap  and <code>0,1,2,3,</code> should be <code>VALUE</code>s of <code>KEY</code>s.</p>
  
  <p>If it's hard corded, it seems like below:</p>
  
  <pre><code>Map&lt;String, Integer&gt; myMap  = new HashMap&lt;String, Integer&gt;();
  myMap.put("SALES", 0);
  myMap.put("SALE_PRODUCTS", 1);
  myMap.put("EXPENSES", 2);
  myMap.put("EXPENSES_ITEMS", 3);
  </code></pre>