Code qui lit `` src / main / resources / application.yml '' comme une chaîne de caractères pour le moment.
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.FileCopyUtils;
import jp.co.rakuten.firstparty.base.exception.FirstPartyBizException;
public class Hoge {
public static void main(String[] args) {
String path = "application.yml";
try {
String str = new String(FileCopyUtils.copyToByteArray(new ClassPathResource(path).getInputStream()),
StandardCharsets.UTF_8);
System.out.println(str);
} catch (IOException e) {
throw new FirstPartyBizException(e);
}
}
}
Recommended Posts