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 func_72661_a(byte[] p_72661_0_, int p_72661_1_, int p_72661_2_) {
    int var3 = p_72661_2_ - 1;

    int var4;
    for (var4 = p_72661_1_ > var3 ? var3 : p_72661_1_; 0 != p_72661_0_[var4] && var4 < var3; ++var4) {
        ;//from w w  w  .java  2 s  .  c  om
    }

    try {
        return new String(p_72661_0_, p_72661_1_, var4 - p_72661_1_, "UTF-8");
    } catch (UnsupportedEncodingException var6) {
        var6.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static byte[] dataDigest(String in) {
    byte[] sum = null;

    try {//w  w  w . j  a  va2s .  c  om
        MessageDigest md = MessageDigest.getInstance("SHA-1");
        byte[] bytes = in.getBytes("UTF8");
        sum = md.digest(bytes);

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    return sum;
}

From source file:Main.java

public static String getUTFFromISO(String str) {
    try {//  www .  j a  v  a2 s . co m
        if (str == null)
            str = "";
        byte[] buf = str.getBytes("iso-8859-1");
        byte[] buf2 = str.getBytes("UTF-8");
        if (!str.equals(new String(buf2, "UTF-8"))) {
            str = new String(buf, "UTF-8");
        }

        return str;
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return str;
}

From source file:Main.java

public static String getFilePath(File dirPath, String fileName) {
    try {//from   w w w . j  ava  2 s . c  om
        String filePath = dirPath.getAbsolutePath() + File.separator
                + URLEncoder.encode(fileName.replace("*", ""), "UTF-8");
        return filePath;
    } catch (final UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    return null;

}

From source file:Main.java

public static final String mapToQueryString(HashMap<String, String> queryString) {
    StringBuilder sb = new StringBuilder();
    try {/*  w ww  . java  2  s .  c  o  m*/
        for (HashMap.Entry<String, String> e : queryString.entrySet()) {
            if (sb.length() > 0) {
                sb.append('&');
            }
            sb.append(URLEncoder.encode(e.getKey(), "UTF-8")).append('=')
                    .append(URLEncoder.encode(e.getValue(), "UTF-8"));
        }
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }
    return sb.toString();
}

From source file:Main.java

public static InputStream getStringStream(String sInputString) {
    ByteArrayInputStream tInputStringStream = null;
    if (sInputString != null && !sInputString.trim().equals("")) {
        byte[] bytes;
        try {/*  w  w w.  j a v  a  2  s  .  co m*/
            bytes = sInputString.getBytes("UTF-8");
            tInputStringStream = new ByteArrayInputStream(bytes);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

    }
    return tInputStringStream;
}

From source file:Main.java

public static String gb2312ToUtf8(String str) {

    String urlEncode = "";

    try {/*from   www. j av  a 2s.  co m*/

        urlEncode = URLEncoder.encode(str, "UTF-8");

    } catch (UnsupportedEncodingException e) {

        e.printStackTrace();

    }

    return urlEncode;

}

From source file:Main.java

public static String serializerXmlString(Object xmlObj) throws JAXBException, ParserConfigurationException {
    ByteArrayOutputStream baos = (ByteArrayOutputStream) serializerOutputStream(xmlObj);
    byte[] bystr = baos.toByteArray();
    String str = "";
    try {//  w  ww . j  av  a  2s  .c o m
        str = new String(bystr, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return str;
}

From source file:Main.java

public static boolean isValidBillTitleLength(String str) {
    if (!isValidString(str))
        return false;

    boolean res = false;

    try {/*w ww  . j av a 2  s.c o m*/
        byte[] bytes = str.getBytes("GBK");

        if (bytes.length <= 32)
            res = true;
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    return res;
}

From source file:Main.java

public static String encodeURL(String raw, String charsetName) {
    if (raw == null) {
        return null;
    }//from  w w w.j a v a2  s  . c om
    try {
        if (TextUtils.isEmpty(charsetName)) {
            charsetName = Charset.defaultCharset().displayName();
        }
        return URLEncoder.encode(raw, charsetName);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return null;
    }
}