ClassPathResource
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import java.io.File;
import java.io.InputStream;
Resource resource = new ClassPathResource("test-dir/test.txt");
InputStream input = resource.getInputStream();
File file = resource.getFile();
ResourceLoader
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import java.io.File;
import java.io.InputStream;
@Autowired
private ResourceLoader resourceLoader;
Resource resource = resourceLoader.getResource("classpath:test-dir/test.txt");
InputStream input = resource.getInputStream();
File file = resource.getFile();
@Value
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
@Value("classpath:test-dir/test.txt")
private Resource resource;