List of usage examples for java.net URLDecoder decode
public static String decode(String s, Charset charset)
From source file:Main.java
public static final String urlDecode(String encode) { try {//from ww w . j a va2 s .co m return URLDecoder.decode(encode, charset.toString()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return encode; }
From source file:Main.java
public static String decode(final String content, final String encoding) { try {//ww w . j a v a 2 s. co m return URLDecoder.decode(content, encoding != null ? encoding : DEFAULT_CONTENT_CHARSET); } catch (UnsupportedEncodingException problem) { throw new IllegalArgumentException(problem); } }
From source file:Main.java
public static String resolvePath(final String path) { try {//from w w w . j a v a2s . co m final URI uri = new URI(path); return removeExtraSlashes(URLDecoder.decode(uri.getPath(), "UTF-8")); } catch (final Exception e) { throw new RuntimeException(e); } }
From source file:Main.java
public static String changeSizeThumbURL(String url, final int sizeWidthOfItem) { if ((url == null) || url.equals("")) { return url; }//w w w. ja v a 2s . c om try { url = URLDecoder.decode(url, "UTF-8"); } catch (final UnsupportedEncodingException e) { e.printStackTrace(); } if (url.contains("/thumb_w/") && url.contains(",") && ((url.indexOf("/thumb_w/") + 5) < url.indexOf(","))) { final int size = (sizeWidthOfItem + 100) - (sizeWidthOfItem % 100); if ((size > 0) && (size < 1000) && ((size % 100) == 0)) { url = url.substring(0, url.indexOf("/thumb_w/")) + "/thumb_w/" + size + url.substring(url.indexOf(","), url.length()); } } return url; }
From source file:Main.java
public static String toURLDecoded(String paramString) { if (paramString == null || paramString.equals("")) { return ""; }/* w w w . j av a 2s . c om*/ try { String str = new String(paramString.getBytes(), "UTF-8"); str = URLDecoder.decode(str, "UTF-8"); return str; } catch (Exception localException) { // Log.i("--","toURLDecoded error:"+paramString, localException); } return ""; }
From source file:Main.java
private static String decode(final String content, final String encoding) { try {/* w w w .j a va 2 s.c o m*/ return URLDecoder.decode(content, encoding != null ? encoding : DEFAULT_CONTENT_CHARSET); } catch (UnsupportedEncodingException problem) { throw new IllegalArgumentException(problem); } }
From source file:Main.java
public static String findValueInUrl(String url, String key) { String[] params = url.split("&"); String value = ""; for (String p : params) { if (p.contains(key)) { try { value = URLDecoder.decode(p.split("=")[1], "utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace();// w w w. j a v a2 s . c o m } } } return value; }
From source file:Main.java
/** * Hides the irritating declared exception. * * @return null if there is an IllegalArgumentException * @throws RuntimeException//from ww w . ja v a 2 s . c om * if there is an UnsupportedEncodingException */ public static String decode(String value) { try { return URLDecoder.decode(value, "utf-8"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } catch (IllegalArgumentException ex) { return null; } }
From source file:Main.java
/** * Decodes an URL encoded String <code>s</code> using the UTF-8 character * encoding./*from w w w .j a v a 2s .c om*/ * * @param s an encoded String * @return the decoded String */ public static String decode(final String s) { if (s == null) { return null; } try { return URLDecoder.decode(s, "UTF-8"); } catch (final UnsupportedEncodingException ignored) { } return null; }
From source file:Main.java
public static String getUrlStatus(String ss) { String st = ""; try {/*from w w w. j av a 2s . c om*/ st = URLDecoder.decode(ss.replaceAll("\\+", "-000000000000000-"), "utf-8") .replaceAll("-000000000000000-", "+"); } catch (UnsupportedEncodingException e) { Log.d("decode", ss, e); } return st.substring("file:".length(), st.length()).replaceAll("///", "/").replaceAll("//", "/"); }