vineri, 8 mai 2015

[OmniFaces utilities 2.0] URL encode/decode


[OmniFaces utilities] The encodeURL() method URL-encode the given string using UTF-8.
[OmniFaces utilities] The decodeURL() method URL-decode the given string using UTF-8.

Method Utils#encodeURL() - URL-encode the given string using UTF-8, based on java.net.URLEncoder

Method Utils#decodeURL() - URL-decode the given string using UTF-8 based on java.net.URLDecoder
Usage:

import org.omnifaces.util.Utils;
...
// https%3A%2F%2Fus-mg6.mail.yahoo.com%2Fneo%2Flaunch%3F.rand%3Ddhiv2ate4r8dj%236128537129
String encoded = Utils.encodeURL("https://us-mg6.mail.yahoo.com/neo/launch?.rand=dhiv2ate4r8dj#6128537129");

// https://us-mg6.mail.yahoo.com/neo/launch?.rand=dhiv2ate4r8dj#6128537129
String dencoded = Utils.decodeURL(encoded);

Niciun comentariu:

Trimiteți un comentariu