public static String reverse(String str) {
      if (str == null) {
          return null;
      }
      return new StringBuffer(str).reverse().toString();
  }
public static String reverse ( String str ) { if ( str == null ) { return null ; } return new StringBuffer ( str ) . reverse ( ) . toString ( ) ; }
<p>Reverses a String as per {@link StringBuffer#reverse()}.</p>

<p>A <code>null</code> String returns <code>null</code>.</p>

<pre>
GosuStringUtil.reverse(null)  = null
GosuStringUtil.reverse("")    = ""
GosuStringUtil.reverse("bat") = "tab"
</pre>

@param str  the String to reverse, may be null
@return the reversed String, <code>null</code> if null String input