首页 > Web开发 > 详细

区划代码-json

时间:2015-10-28 12:35:21      阅读:220      评论:0      收藏:0      [点我收藏+]
 Map<String, Map<String, Set<String>>> provines = new HashMap<String, Map<String,Set<String>>>();
		 
		
		BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\aredDiv.json")));
		List<String> lines = IOUtils.readLines(bf);
		for (String line : lines) {
			String[] sourceStrArray = line.split(":");

			for (int i = 0; i < sourceStrArray.length; i++) {
				String realy = sourceStrArray[0].replace("\"", "").trim();
				String add = sourceStrArray[1].trim();
				if (i == 0) {
					String str = realy;
					int key = Integer.parseInt(str);
					if (key % 10000 == 0) {
						System.out.println("};");
						System.out.println("addCity(addr, set);");
						System.out.println("city = new HashMap<String, Set<String>>();");
						System.out.println("provines.put(" + add + ", city);");
						
					}
					if (key % 100 == 0 && key % 10000 != 0) {
						System.out.println("};");
						System.out.println("set = new HashSet<String>();");
						System.out.println("city.put(" + add + ", set);");
						System.out.println("addr = new String[] {");
						
					} else {
						System.out.println(" ,"+add);

					}

				}
			}

		}

		String s = "吉林省朝阳区xxxx";

		
		
		int index = s.indexOf("省");
		System.out.println(index);
		String province = s.substring(0, index + 1);
		System.out.println(province);
		if (s.contains("县")) {

			String city = s.substring(index + 1, s.indexOf("县") + 1);
			System.out.println(getParentCity(province, city));

			return;
		}
		if (s.contains("区")) {
			String city = s.substring(index + 1, s.indexOf("区") + 1);
			System.out.println(getParentCity(province, city));
			return;
		}

		// System.out.println(city);

  

区划代码-json

原文:http://www.cnblogs.com/anni6/p/4916796.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!