private static String getCurrName(String provinceId) { try { LineNumberReader lnr = new LineNumberReader( new InputStreamReader(DataPrepareUtil.class .getResourceAsStream("/idcard_address.txt"), "GBK")); String line = lnr.readLine(); while (line != null) { String[] str = line.replace(" ", "").split(" "); int code = Integer.parseInt(StringUtils.trim(str[0])); if (provinceId.length() == 2 && Integer.parseInt(provinceId) * 10000 == code) { return StringUtils.trim(str[1]); } if (provinceId.length() == 4 && Integer.parseInt(provinceId) * 100 == code) { return StringUtils.trim(str[1]); } if (provinceId.length() == 6 && Integer.parseInt(provinceId) == code) { return StringUtils.trim(str[1]); } line = lnr.readLine(); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return null; }
时间: 2024-10-06 00:24:14