import com.findingroof.util.config.BankConfigConstant;
import net.sf.json.JSONObject;
/**
* @author
* 根据银行卡号查询银行卡类型工具类
* Created by Administrator on 2017/11/1.
*/
public class BankAscriptionUtil {
public static void main(String[] args) {
String s = bankAscription("参数:银行卡卡号");
System.out.print(s);
}
public static String bankAscription(String bankId) {
//通过调用这个网址接口获取银行类型缩写"BOC" //列如:"BOC", "中国银行"
String url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?
_input_charset=utf-8&cardNo=" + bankId + "&cardBinCheck=true";
String name = null;
JSONObject json = null;
String strJson = null;
String statStr = "ok";
try {
String str = URLUtil.getReturnData(url);
json = JSONObject.fromObject(str);
if (json.get("stat").equals(statStr)) {
strJson = (String) json.get("bank");
if(!(strJson ==null)) {
name = BankConfigConstant.Bank_ITEM_NAME.get(strJson);
return name;
}else{
return BankConfigConstant.Bank_type;
}
} else {
return BankConfigConstant.Bank_type;
}
} catch (Exception e) {
e.printStackTrace();
}
return name;
}
}
//银行类型缩写匹配银行类
import java.util.HashMap;
import java.util.Map;
/**@author
* Created by Administrator on 2017/xx/xx.
*/
public class BankConfigConstant {
public static Map<String, String> Bank_ITEM_NAME = new HashMap();
static {
Bank_ITEM_NAME.put("SRCB","深圳农村商业银行");
Bank_ITEM_NAME.put("BGB","广西北部湾银行");
Bank_ITEM_NAME.put("SHRCB","上海农村商业银行");
Bank_ITEM_NAME.put("BJBANK","北京银行");
Bank_ITEM_NAME.put("WHCCB","威海市商业银行");
Bank_ITEM_NAME.put("BOZK", "周口银行");
Bank_ITEM_NAME.put("KORLABANK","库尔勒市商业银行");
Bank_ITEM_NAME.put("SPABANK", "平安银行");
Bank_ITEM_NAME.put("SDEB", "顺德农商银行");
Bank_ITEM_NAME.put("HURCB", "湖北省农村信用社");
Bank_ITEM_NAME.put("WRCB", "无锡农村商业银行");
Bank_ITEM_NAME.put("BOCY", "朝阳银行");
Bank_ITEM_NAME.put("CZBANK", "浙商银行");
Bank_ITEM_NAME.put("HDBANK", "邯郸银行");
Bank_ITEM_NAME.put("BOC", "中国银行");
Bank_ITEM_NAME.put("BOD","东莞银行");
Bank_ITEM_NAME.put("CCB","中国建设银行");
Bank_ITEM_NAME.put("ZYCBANK","遵义市商业银行");
Bank_ITEM_NAME.put( "SXCB","绍兴银行");
Bank_ITEM_NAME.put( "GZRCU","贵州省农村信用社");
Bank_ITEM_NAME.put("ZJKCCB","张家口市商业银行");
Bank_ITEM_NAME.put("BOJZ","锦州银行");
Bank_ITEM_NAME.put("BOP","平顶山银行");
Bank_ITEM_NAME.put("HKB","汉口银行");
Bank_ITEM_NAME.put( "SPDB","上海浦东发展银行");
Bank_ITEM_NAME.put("NXRCU","宁夏黄河农村商业银行");
Bank_ITEM_NAME.put("NYNB", "广东南粤银行");
Bank_ITEM_NAME.put("GRCB", "广州农商银行");
Bank_ITEM_NAME.put("BOSZ", "苏州银行");
Bank_ITEM_NAME.put("HZCB", "杭州银行");
Bank_ITEM_NAME.put("HSBK","衡水银行");
Bank_ITEM_NAME.put("HBC","湖北银行");
Bank_ITEM_NAME.put("JXBANK","嘉兴银行");
Bank_ITEM_NAME.put("HRXJB","华融湘江银行");
Bank_ITEM_NAME.put("BODD","丹东银行");
Bank_ITEM_NAME.put("AYCB","安阳银行");
Bank_ITEM_NAME.put("EGBANK","恒丰银行");
Bank_ITEM_NAME.put("CDB","国家开发银行");
Bank_ITEM_NAME.put("TCRCB","江苏太仓农村商业银行");
Bank_ITEM_NAME.put( "NJCB","南京银行");
Bank_ITEM_NAME.put("ZZBANK","郑州银行");
Bank_ITEM_NAME.put("DYCB","德阳商业银行");
Bank_ITEM_NAME.put("YBCCB","宜宾市商业银行");
Bank_ITEM_NAME.put("SCRCU","四川省农村信用");
Bank_ITEM_NAME.put("KLB","昆仑银行");
Bank_ITEM_NAME.put("LSBANK","莱商银行");
Bank_ITEM_NAME.put("YDRCB","尧都农商行");
Bank_ITEM_NAME.put("CCQTGB","重庆三峡银行");
Bank_ITEM_NAME.put("FDB","富滇银行");
Bank_ITEM_NAME.put("JSRCU","江苏省农村信用联合社");
Bank_ITEM_NAME.put("JNBANK","济宁银行");
Bank_ITEM_NAME.put("CMB","招商银行");
Bank_ITEM_NAME.put("JINCHB","晋城银行JCBANK");
Bank_ITEM_NAME.put("FXCB","阜新银行");
Bank_ITEM_NAME.put("WHRCB","武汉农村商业银行");
Bank_ITEM_NAME.put( "HBYCBANK","湖北银行宜昌分行");
Bank_ITEM_NAME.put("TZCB","台州银行");
Bank_ITEM_NAME.put("TACCB","泰安市商业银行");
Bank_ITEM_NAME.put("XCYH","许昌银行");
Bank_ITEM_NAME.put("CEB","中国光大银行");
Bank_ITEM_NAME.put("NXBANK","宁夏银行");
Bank_ITEM_NAME.put("HSBANK","徽商银行");
Bank_ITEM_NAME.put("JJBANK","九江银行");
Bank_ITEM_NAME.put("NHQS","农信银清算中心");
Bank_ITEM_NAME.put("MTBANK","浙江民泰商业银行");
Bank_ITEM_NAME.put("LANGFB","廊坊银行");
Bank_ITEM_NAME.put("ASCB","鞍山银行");
Bank_ITEM_NAME.put("KSRB","昆山农村商业银行");
Bank_ITEM_NAME.put("YXCCB","玉溪市商业银行");
Bank_ITEM_NAME.put("DLB","大连银行");
Bank_ITEM_NAME.put("DRCBCL","东莞农村商业银行");
Bank_ITEM_NAME.put("GCB","广州银行");
Bank_ITEM_NAME.put("NBBANK","宁波银行");
Bank_ITEM_NAME.put("BOYK","营口银行");
Bank_ITEM_NAME.put("SXRCCU","陕西信合");
Bank_ITEM_NAME.put("GLBANK","桂林银行");
Bank_ITEM_NAME.put("BOQH","青海银行");
Bank_ITEM_NAME.put("CDRCB","成都农商银行");
Bank_ITEM_NAME.put("QDCCB","青岛银行");
Bank_ITEM_NAME.put("HKBEA","东亚银行");
Bank_ITEM_NAME.put("HBHSBANK","湖北银行黄石分行");
Bank_ITEM_NAME.put( "WZCB","温州银行");
Bank_ITEM_NAME.put("TRCB","天津农商银行");
Bank_ITEM_NAME.put("QLBANK","齐鲁银行");
Bank_ITEM_NAME.put("GDRCC","广东省农村信用社联合社");
Bank_ITEM_NAME.put("ZJTLCB","浙江泰隆商业银行");
Bank_ITEM_NAME.put("GZB","赣州银行");
Bank_ITEM_NAME.put("GYCB","贵阳市商业银行");
Bank_ITEM_NAME.put("CQBANK","重庆银行");
Bank_ITEM_NAME.put("DAQINGB","龙江银行");
Bank_ITEM_NAME.put("9000AZ", "已完成");
Bank_ITEM_NAME.put( "CGNB","南充市商业银行");
Bank_ITEM_NAME.put("SCCB","三门峡银行");
Bank_ITEM_NAME.put("CSRCB","常熟农村商业银行");
Bank_ITEM_NAME.put("SHBANK","上海银行");
Bank_ITEM_NAME.put("JLBANK","吉林银行");
Bank_ITEM_NAME.put("CZRCB","常州农村信用联社");
Bank_ITEM_NAME.put("BANKWF","潍坊银行");
Bank_ITEM_NAME.put("ZRCBANK","张家港农村商业银行");
Bank_ITEM_NAME.put("FJHXBC","福建海峡银行");
Bank_ITEM_NAME.put("ZJNX","浙江省农村信用社联合社");
Bank_ITEM_NAME.put("LZYH","兰州银行");
Bank_ITEM_NAME.put("JSB","晋商银行");
Bank_ITEM_NAME.put("BOHAIB","渤海银行");
Bank_ITEM_NAME.put("CZCB","浙江稠州商业银行");
Bank_ITEM_NAME.put("YQCCB","阳泉银行");
Bank_ITEM_NAME.put("SJBANK","盛京银行");
Bank_ITEM_NAME.put("XABANK","西安银行");
Bank_ITEM_NAME.put("XTB","邢台银行");
Bank_ITEM_NAME.put("JSBANK","江苏银行");
Bank_ITEM_NAME.put("FSCB","抚顺银行");
Bank_ITEM_NAME.put("HNRCU","河南省农村信用");
Bank_ITEM_NAME.put("COMM","交通银行");
Bank_ITEM_NAME.put("XTB","邢台银行");
Bank_ITEM_NAME.put("CITIC","中信银行");
Bank_ITEM_NAME.put("HXBANK","华夏银行");
Bank_ITEM_NAME.put("HNRCC","湖南省农村信用社");
Bank_ITEM_NAME.put("DYCCB","东营市商业银行");
Bank_ITEM_NAME.put("ORBANK","鄂尔多斯银行");
Bank_ITEM_NAME.put("BJRCB","北京农村商业银行");
Bank_ITEM_NAME.put("XYBANK","信阳银行");
Bank_ITEM_NAME.put("ZGCCB","自贡市商业银行");
Bank_ITEM_NAME.put("CDCB","成都银行");
Bank_ITEM_NAME.put("HANABANK","韩亚银行");
Bank_ITEM_NAME.put("CMBC","中国民生银行");
Bank_ITEM_NAME.put("LYBANK","洛阳银行");
Bank_ITEM_NAME.put("GDB","广东发展银行");
Bank_ITEM_NAME.put("ZBCB","齐商银行");
Bank_ITEM_NAME.put("CBKF","开封市商业银行");
Bank_ITEM_NAME.put("H3CB","内蒙古银行");
Bank_ITEM_NAME.put("CIB","兴业银行");
Bank_ITEM_NAME.put("CRCBANK","重庆农村商业银行");
Bank_ITEM_NAME.put("SZSBK","石嘴山银行");
Bank_ITEM_NAME.put("DZBANK","德州银行");
Bank_ITEM_NAME.put("SRBANK","上饶银行");
Bank_ITEM_NAME.put("LSCCB","乐山市商业银行");
Bank_ITEM_NAME.put("JXRCU","江西省农村信用");
Bank_ITEM_NAME.put("ICBC","中国工商银行");
Bank_ITEM_NAME.put("JZBANK","晋中市商业银行");
Bank_ITEM_NAME.put("HZCCB","湖州市商业银行");
Bank_ITEM_NAME.put("NHB","南海农村信用联社");
Bank_ITEM_NAME.put("XXBANK","新乡银行");
Bank_ITEM_NAME.put("JRCB","江苏江阴农村商业银行");
Bank_ITEM_NAME.put("YNRCC","云南省农村信用社");
Bank_ITEM_NAME.put("ABC","中国农业银行");
Bank_ITEM_NAME.put("GXRCU","广西省农村信用");
Bank_ITEM_NAME.put("PSBC","中国邮政储蓄银行");
Bank_ITEM_NAME.put("BZMD","驻马店银行");
Bank_ITEM_NAME.put("ARCU","安徽省农村信用社");
Bank_ITEM_NAME.put("GSRCU","甘肃省农村信用");
Bank_ITEM_NAME.put("LYCB","辽阳市商业银行");
Bank_ITEM_NAME.put("JLRCU","吉林农信");
Bank_ITEM_NAME.put("URMQCCB","乌鲁木齐市商业银行");
Bank_ITEM_NAME.put("XLBANK","中山小榄村镇银行");
Bank_ITEM_NAME.put("CSCB","长沙银行");
Bank_ITEM_NAME.put("JHBANK","金华银行");
Bank_ITEM_NAME.put("BHB","河北银行");
Bank_ITEM_NAME.put("NBYZ","鄞州银行");
Bank_ITEM_NAME.put("LSBC","临商银行");
Bank_ITEM_NAME.put("BOCD","承德银行");
Bank_ITEM_NAME.put("SDRCU","山东农信");
Bank_ITEM_NAME.put("NCB","南昌银行");
Bank_ITEM_NAME.put("TCCB","天津银行");
Bank_ITEM_NAME.put("WJRCB","吴江农商银行");
Bank_ITEM_NAME.put("CBBQS","城市商业银行资金清算中心");
Bank_ITEM_NAME.put("HBRCU","河北省农村信用社");
}
public static String Bank_type ="暂不支持此银行,请核对后输入";
}
然后就可以直接引用main方法测试啦