Skip to content

Commit

Permalink
json 못 찾는 에러 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
SeWooooong committed Aug 11, 2024
1 parent 30523b5 commit 8464ac7
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.example.mssaembackendv2.global.common;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import lombok.RequiredArgsConstructor;
Expand All @@ -15,8 +17,9 @@ public String getCommunityTermsJson() throws IOException {
// ClassPathResource를 이용해 JSON 파일 읽어오기
ClassPathResource resource = new ClassPathResource("community-terms.json");

// 파일 내용을 String으로 변환
Path path = resource.getFile().toPath();
return new String(Files.readAllBytes(path));
// InputStream을 이용해 파일 내용을 String으로 변환
try (InputStream inputStream = resource.getInputStream()) {
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
}
}
}

0 comments on commit 8464ac7

Please sign in to comment.