标签:
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);
标签:
原文地址:http://www.cnblogs.com/anni6/p/4916796.html