Code that reads src / main / resources / application.yml
as a string for the time being.
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