load a file from classpath spring boot

import org.springframework.core.io.ClassPathResource;
import org.springframework.util.FileCopyUtils;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

public class FileLoader {

    public String loadFileFromClasspath(String filePath) throws IOException {
        ClassPathResource resource = new ClassPathResource(filePath);
        InputStream inputStream = resource.getInputStream();
        byte[] data = FileCopyUtils.copyToByteArray(inputStream);
        return new String(data, StandardCharsets.UTF_8);
    }
}