title: Cleaner way to check if a string is ISO country of ISO language in Java
body: <p>Suppose to have a two-characters <code>String</code>, which should represent the <strong>ISO 639</strong> country or language name.</p>
  
  <p>You know, <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Locale.htm" rel="noreferrer"><code>Locale</code></a> class has two functions <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#getISOLanguages%28%29" rel="noreferrer"><code>getISOLanguages</code></a> and <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#getISOCountries%28%29" rel="noreferrer"><code>getISOCountries</code></a> that return an array of <code>String</code> with all the ISO languages and ISO countries, respectively.</p>
  
  <p>To check if a specific <code>String</code> object is a valid ISO language or ISO country I should look inside that arrays for a matching <code>String</code>. Ok, I can do that by using a binary search (e.g. <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#binarySearch%28T%5B%5D,%20T,%20java.util.Comparator%29" rel="noreferrer"><code>Arrays.binarySearch</code></a> or the ApacheCommons <a href="http://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/ArrayUtils.html#contains%28java.lang.Object%5B%5D,%20java.lang.Object%29" rel="noreferrer"><code>ArrayUtils.contains</code></a>).</p>
  
  <p>The question is: <strong>exists any utility</strong> (e.g. from <em>Guava</em> or <em>Apache Commons</em> libraries) <strong>that provides a cleaner way, e.g. a function that returns a <code>boolean</code> to validate a <code>String</code> as a valid ISO 639 language or ISO 639 Country</strong>?</p>
  
  <p>For instance:</p>
  
  <pre><code>public static boolean isValidISOLanguage(String s)
  public static boolean isValidISOCountry(String s)
  </code></pre>