title: Is there an existing library method that checks if a String is all upper case or lower case in Java?
body: <p>I know there are plenty of <code>upper()</code> methods in Java and other frameworks like Apache commons lang, which convert a String to all upper case.</p>
  
  <p>Are there any common libraries that provide a method like <code>isUpper(String s)</code> and <code>isLower(String s)</code>, to check if all the characters in the String are upper or lower case?</p>
  
  <p>EDIT:</p>
  
  <p>Many good answers about converting to Upper and comparing to this. I guess I should have been a bit more specific, and said that I already had thought of that, but I was hoping to be able to use an existing method for this.</p>
  
  <p>Good comment about possible inclusion of this in apache.commons.lang.StringUtils.
  Someone has even submitted a patch (20090310). Hopefully we will see this soon.
  <a href="https://issues.apache.org/jira/browse/LANG-471" rel="noreferrer">https://issues.apache.org/jira/browse/LANG-471</a></p>
  
  <p>EDIT:</p>
  
  <p>What I needed this method for, was to capitalize names of hotels that sometimes came in all uppercase. I only wanted to capitalize them if they were all lower or upper case.
  I did run in to the problems with non letter chars mentioned in some of the posts, and ended up doing something like this:</p>
  
  <pre><code>private static boolean isAllUpper(String s) {
      for(char c : s.toCharArray()) {
         if(Character.isLetter(c) &amp;&amp; Character.isLowerCase(c)) {
             return false;
          }
      }
      return true;
  }
  </code></pre>
  
  <p>This discussion and differing solutions (with different problems), clearly shows that there is a need for a good solid isAllUpper(String s) method in commons.lang</p>
  
  <p>Until then I guess that the <code>myString.toUpperCase().equals(myString)</code> is the best way to go.</p>