Last active
May 22, 2019 05:41
-
-
Save bllli/03f45983060d3a8a26ccce91010d9784 to your computer and use it in GitHub Desktop.
[SpringBoot] Spring的一些基础应用 #Spring #Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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