I have checked your code.If you would like to load a file from classpath in a Spring Boot JAR, then you have to use the resource.getInputStream() rather than resource.getFile().If you try to use resource.getFile() you will receive an error, because Spring tries to access a file system path, but it can not access a path in your JAR.
detail as below:
https://smarterco.de/java-load-file-classpath-spring-boot/
Please try resourceLoader.getResource("classpath:static/Sample.txt");
Working with this code when run with java -jar XXXX.jar

------ update ------
After go through your codes, the problem is you try to read the file by the FileInputStream but actually it's inside the jar file.
But actually you get the org.springframework.core.io.Resource so means you cat get the InputStream, so you can do it like new BufferedReader(new InputStreamReader(resource.getInputStream())).readLine();