List of usage examples for java.net URLEncoder encode
public static String encode(String s, Charset charset)
From source file:Main.java
public static String getEncodedString(String toEncode) throws Exception { if (toEncode == null) return ""; return URLEncoder.encode(toEncode, "utf-8"); }
From source file:Main.java
public static String getGb2312Encode(String s) throws UnsupportedEncodingException { return URLEncoder.encode(s, "gb2312"); }
From source file:Main.java
public static String UrlEncoder(String str, String cahrset) { try {/*w w w . j av a 2s. c o m*/ return URLEncoder.encode(str, cahrset); } catch (UnsupportedEncodingException e) { return str; } }
From source file:Main.java
public static String getEncodedPhoneModel() { String model = ""; try {/*from w ww . j a v a2 s . co m*/ model = URLEncoder.encode(Build.MODEL, "UTF-8"); } catch (Exception e) { } return model; }
From source file:Main.java
public static final String encode(String content) { try {// w w w . j a va2s.c om return content == null ? null : URLEncoder.encode(content, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
From source file:Main.java
public static String encodeUrlParam(String s) { try {/*from w w w.ja va 2 s . c o m*/ return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException ex) { throw new AssertionError("UTF-8 should always be supported", ex); } }
From source file:Main.java
private static String urlEncode(String str) { try {/*from w w w.j a v a 2 s. c om*/ return URLEncoder.encode(str, ENCODE).replace("%2F", "/"); } catch (UnsupportedEncodingException e) { return null; } }
From source file:Main.java
public static String urlEncode(String stringToEncode) { String stringEncoded;//from w w w. ja va2s . c om try { stringEncoded = URLEncoder.encode(stringToEncode, "UTF-8"); } catch (UnsupportedEncodingException e) { stringEncoded = null; e.printStackTrace(); } return stringEncoded; }
From source file:Main.java
public static String encodeingUrl(String url) { try {//from w w w. ja v a 2s. c om return URLEncoder.encode(url, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return replaceSpace(url); }
From source file:Main.java
public static String gb2312ToUtf8(String str) { String urlEncode = ""; try {/*from w w w . j a v a2s . c o m*/ urlEncode = URLEncoder.encode(str, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return urlEncode; }