import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import java.io.IOException;
import java.nio.file.Files;
public class ClasspathFileLoadingExample {
public static void main(String[] args) throws IOException {
ResourceLoader resourceLoader = new DefaultResourceLoader();
Resource resource = resourceLoader.getResource("classpath:myFile.txt");
byte[] bytes = Files.readAllBytes(resource.getFile().toPath());
String fileContent = new String(bytes);
System.out.println(fileContent);
}
}