4040import com .google .common .cache .CacheLoader ;
4141import com .google .common .cache .LoadingCache ;
4242
43+ import static java .nio .charset .StandardCharsets .UTF_8 ;
44+
4345public class TextUtils {
4446 private static final String FIRSTWORD = "^([^\\ s]*).*$" ;
4547
@@ -279,14 +281,11 @@ public static String exceptionToString(String message, Throwable e) {
279281 * @param s String to escape
280282 * @return URL-escaped string
281283 */
282- @ SuppressWarnings ("deprecation" )
283284 public static String urlEscape (String s ) {
284285 try {
285- return URLEncoder .encode (s ,"UTF8" );
286+ return URLEncoder .encode (s , UTF_8 . name () );
286287 } catch (UnsupportedEncodingException e ) {
287- // should be impossible; all JVMs must support UTF8
288- // but have a fallback just in case
289- return URLEncoder .encode (s );
288+ return s ;
290289 }
291290 }
292291
@@ -296,14 +295,11 @@ public static String urlEscape(String s) {
296295 * @param s String do unescape
297296 * @return URL-unescaped String
298297 */
299- @ SuppressWarnings ("deprecation" )
300298 public static String urlUnescape (String s ) {
301299 try {
302- return URLDecoder .decode (s , "UTF8" );
300+ return URLDecoder .decode (s , UTF_8 . name () );
303301 } catch (UnsupportedEncodingException e ) {
304- // should be impossible; all JVMs must support UTF8
305- // but have a fallback just in case
306- return URLDecoder .decode (s );
302+ return s ;
307303 }
308304 }
309305}
0 commit comments