List of usage examples for java.io UnsupportedEncodingException printStackTrace
public void printStackTrace()
From source file:Main.java
public static final String urlEncode(String url) { try {/*from w ww .j a va 2s.c om*/ return URLEncoder.encode(url, charset.toString()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return url; }
From source file:Main.java
public static String urlEncode(String key) { String result = key;// www. j a va2s .co m try { result = URLEncoder.encode(key, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return result; }
From source file:Main.java
public static final String urlDecode(String encode) { try {/* www . j a va 2 s . com*/ return URLDecoder.decode(encode, charset.toString()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return encode; }
From source file:Main.java
public static String base64decode(String base64) { String decoded = ""; try {/* ww w . ja v a 2 s.c o m*/ decoded = new String(Base64.decode(base64, Base64.DEFAULT), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return decoded; }
From source file:Main.java
public static String iso2utf8(String iso) { try {/*from w w w .jav a2s.c o m*/ String utf8 = new String(iso.getBytes("iso8859-1"), "utf-8"); return utf8; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return iso; }
From source file:Main.java
public static String str2Code(String str, String code) { try {//w w w . j a v a 2 s. com str = new String(str.getBytes(), code); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } return str; }
From source file:Main.java
public static String decodeString(String base64String) { byte[] data = Base64.decode(base64String, Base64.DEFAULT); String text = null;// w w w . j av a 2s . com try { text = new String(data, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return text; }
From source file:Main.java
/** byte[] -> String */ public static String bytesToString(byte[] bytes) { String str = ""; try {//from w ww . j a v a 2 s.c om str = new String(bytes, "UTF-8"); // ISO-8859-1 } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return str; }
From source file:Main.java
public static String decodeBase64(String encodedString) { byte[] byteData = Base64.decode(encodedString, Base64.NO_WRAP); String decodedString = null;// ww w . j av a 2 s .com try { decodedString = new String(byteData, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return decodedString; }
From source file:Main.java
public static final byte[] getGB2312ByteArray(String str) { byte[] tmp;//from w ww .j ava 2 s .c o m try { tmp = str.getBytes("GB2312"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return null; } return tmp; }