package com.weike.platform.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class BankErrorCodeUtil {
private static Properties properties=null;
static{
if(null==properties){
properties = new Properties();
InputStream in = null;
try {
in = BankErrorCodeUtil.class.getClassLoader().getResourceAsStream("bank-error-code.properties");
properties.load(in);
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 添加错误编码
* @param key
* @param value
* @return
*/
public static boolean addErrorCode(String key,String value){
boolean flag = false;
try{
properties.put(key, value);
flag = true;
}catch(Exception e){
e.printStackTrace();
}
return flag;
}
/**
* 验证错误编码
* @param key
* @return
*/
public static boolean checkErrorCode(String key){
return properties.containsKey(key);
}
/**
* 获取错误信息
* @param key
* @return
*/
public static String getErrorText(String key){
return properties.get(key).toString();
}
}
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class BankErrorCodeUtil {
private static Properties properties=null;
static{
if(null==properties){
properties = new Properties();
InputStream in = null;
try {
in = BankErrorCodeUtil.class.getClassLoader().getResourceAsStream("bank-error-code.properties");
properties.load(in);
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 添加错误编码
* @param key
* @param value
* @return
*/
public static boolean addErrorCode(String key,String value){
boolean flag = false;
try{
properties.put(key, value);
flag = true;
}catch(Exception e){
e.printStackTrace();
}
return flag;
}
/**
* 验证错误编码
* @param key
* @return
*/
public static boolean checkErrorCode(String key){
return properties.containsKey(key);
}
/**
* 获取错误信息
* @param key
* @return
*/
public static String getErrorText(String key){
return properties.get(key).toString();
}
}