Skip to content

Instantly share code, notes, and snippets.

@bllli
Last active May 22, 2019 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bllli/03f45983060d3a8a26ccce91010d9784 to your computer and use it in GitHub Desktop.
Save bllli/03f45983060d3a8a26ccce91010d9784 to your computer and use it in GitHub Desktop.
[SpringBoot] Spring的一些基础应用 #Spring #Java
// https://stackoverflow.com/questions/44399422/read-file-from-resources-folder-in-spring-boot/44399541
// file path: /path/to/src/main/resources/config/sample.txt
import org.springframework.util.ResourceUtils;
import java.io.File;
import java.nio.file.Files;
File file = ResourceUtils.getFile("classpath:config/sample.txt")
//Read File Content
String content = new String(Files.readAllBytes(file.toPath()));
System.out.println(content);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment