Example usage for java.io UnsupportedEncodingException printStackTrace

List of usage examples for java.io UnsupportedEncodingException printStackTrace

Introduction

In this page you can find the example usage for java.io UnsupportedEncodingException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public static String urlDecode(String url) {
    try {/* w  w  w. j a v  a  2  s. co  m*/
        url = URLDecoder.decode(url, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return url;
}

From source file:Main.java

public static String urlEncode(String url) {
    try {//from w w w.  j a  v  a 2  s .co m
        url = URLEncoder.encode(url, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return url;
}

From source file:Main.java

public static String getEntryComment(ZipEntry entry) {
    try {/*from  www.j  a  va2 s  . c  o  m*/
        return new String(entry.getComment().getBytes("GB2312"), "8859_1");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static String base64Encode(byte[] in) {
    String encoded = null;//from  w w  w . j av  a2 s.co  m
    try {
        encoded = new String(Base64.encode(in, Base64.URL_SAFE | Base64.NO_PADDING), "UTF8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return encoded;
}

From source file:Main.java

public static String urlEncode(String content, String charsetName) {
    try {//from   w  ww.  ja va2s.  c o  m
        return URLEncoder.encode(content, charsetName);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return "";
}

From source file:Main.java

public static String getEntryName(ZipEntry entry) {
    try {// ww  w  .  j  a  v a 2  s .c  o  m
        return new String(entry.getName().getBytes("GB2312"), "8859_1");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static int stringSize(String s) {
    try {/*from   www  .  j  a va 2  s. c  om*/
        String anotherString = new String(s.getBytes("GBK"), "ISO8859_1");
        return anotherString.length();
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
        return 0;
    }
}

From source file:Main.java

public static String urlDecode(String urlCodeStr) {
    String str = null;/* ww  w  .  ja  v  a 2s  .co m*/
    try {
        str = URLDecoder.decode(urlCodeStr, "utf-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return str;
}

From source file:Main.java

public static String encodeString(String toEncode) {
    String toReturn = "";
    try {//from   w w  w . j  av  a  2 s  . c o m
        toReturn = URLEncoder.encode(toEncode, "utf-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return toReturn;
}

From source file:Main.java

private static String urlEncode(String value) {
    try {/*  ww w . j a  v  a 2s  . com*/
        return URLEncoder.encode(value, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    return null;
}