Browse Source

resource/air/airgeo.json을 파일을 jar 실행시 찾을수 없음

file을 stream으로 읽는 것으로 변경
feature/auth
지대한 2 years ago
parent
commit
2b872d6b26
  1. 10
      src/main/java/com/palnet/comn/utils/AreaUtils.java

10
src/main/java/com/palnet/comn/utils/AreaUtils.java

@ -15,6 +15,8 @@ import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
@ -172,14 +174,12 @@ public class AreaUtils {
public void init() throws Exception {
// GeometryFactory geometryFactory = new GeometryFactory();
// 1. file read
Resource resource = new ClassPathResource("air/airgeo.json");
Reader jsonFile = new FileReader(resource.getFile());
ClassPathResource resource = new ClassPathResource("air/airgeo.json");
InputStream jsonInputStream = resource.getInputStream();
// 2. json parsing
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(jsonFile);
JSONObject jsonObject = (JSONObject) jsonParser.parse(new InputStreamReader(jsonInputStream, "UTF-8"));
List<JSONObject> features = (List<JSONObject>) jsonObject.get("features");

Loading…
Cancel
Save