public static String urlEncode(@Nullable String s){
  if (s == null) {
    return "";
  }
  try {
    return URLEncoder.encode(s,"UTF-8");
  }
 catch (  UnsupportedEncodingException e) {
    throw new AssertionError("UTF-8 should be supported in every JVM");
  }
}

public static String urlEncode ( @ Nullable String s ) { if ( s == null ) { return "" ; } try { return URLEncoder . encode ( s , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new AssertionError ( "UTF-8 should be supported in every JVM" ) ; } }
url - encodes a nullable string , catching the useless exception that never happens .
