|
@@ -2,11 +2,11 @@ package com.bosshand.virgo.api.util;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
-import org.springframework.util.ResourceUtils;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
|
|
|
-import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -17,8 +17,9 @@ public class CityUtil {
|
|
|
|
|
|
public static String getCode(String name) {
|
|
|
try {
|
|
|
- File file = ResourceUtils.getFile("classpath:city.json");
|
|
|
- String json = FileUtils.readFileToString(file, "UTF-8");
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("/city.json");
|
|
|
+ InputStream inputStream = classPathResource.getInputStream();
|
|
|
+ String json = IOUtils.toString(inputStream, "UTF-8");
|
|
|
JSONArray jsonArray = JSONObject.parseArray(json);
|
|
|
Map<String, String> code = new HashMap<>();
|
|
|
if (code.size() > 0) {
|