⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icexceptionhandler.java

📁 java接口(关于java调用动态库
💻 JAVA
字号:
package com.jysy.taxcore.comm.exception;

import java.util.Properties;
import java.io.InputStream;
import java.io.*;
import java.net.URL;

/**
 * 异常信息处理类
 *
 * <p>Title: ICExceptionHandler</p>
 * <p>Description: 南京地税税控机IC卡编程接口</p>
 * <p>Copyright: Copyright (c) 2004 广东京粤商用技术有限公司</p>
 * <p>Company: 广东京粤商用技术有限公司</p>
 * @author 李志毅
 * @version 1.0
 */
public class ICExceptionHandler {
    /**
     * 根据异常对象,取出异常描述信息
     * @param e  异常对象, 封装了异常信息
     * @return   该异常的描述信息
     */
    public static String toChinese(String strvalue)
    {
        try {
            if (strvalue == null)
                return null;
            else {
                strvalue = new String(strvalue.getBytes("ISO8859_1"), "GB2312");
                return strvalue;
            }
        }
        catch (Exception e) {
            return null;
        }
    }


    public static String getErrorMsg(TaxBaseICException e) {
        Properties props = new Properties();
        String errInfoResources = e.getErrorInfoResources();
        InputStream is = null;
        try {
            String prefix = ".properties";
            errInfoResources = errInfoResources.trim();
            errInfoResources = errInfoResources.substring(0,
                errInfoResources.length() - prefix.length());
            errInfoResources = errInfoResources.replace('.', '/');
            if (!errInfoResources.startsWith("/")) {
                errInfoResources = "/" + errInfoResources;
            }
            errInfoResources += prefix;

            props.load(props.getClass().getResourceAsStream(errInfoResources));
        }
        catch (Exception ex) {
            props = null;
            ex.printStackTrace();
        }
        finally {
            try {
                if (is != null) {
                    is.close();
                }
            }
            catch (Exception ex) {}
        }

        System.out.println(e.getMessage());
        String errMsg = null;
        if (props == null || (errMsg = toChinese(props.getProperty(e.getMessage()))) == null) {
            errMsg = "未知异常!";
        }

        return errMsg;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -