title: Java Determine If String Starts With Key In Map
body: <p>I want to determine if a given <code>String</code> <code>startsWith</code> any key in a <code>Map</code>.</p>
  
  <p>The simple solution is to iterate through entire the <code>keySet</code>.</p>
  
  <pre><code>private static Map&lt;String, String&gt; someMap;
  
  private static void method(String line) {
      for (String key : someMap.keySet()) {
          if (line.startsWith(key)) {
              // do something with someMap.get(key);
          }
      }
  }
  </code></pre>
  
  <p>My question is: Is there is a better data structure to handle this problem?</p>