Use
Spring DefaultResourceLoader and
Resource to read inside WEB-INF or any resources in a *.jar file.
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
public static void myFunction() throws IOException {
final DefaultResourceLoader loader = new DefaultResourceLoader();
LOGGER.info(loader.getResource(
"classpath:META-INF/resources/img/copyright.png").exists());
Resource resource = loader.getResource(
"classpath:META-INF/resources/img/copyright.png");
BufferedImage watermarkImage = ImageIO.read(resource.getFile());
}
No comments:
Post a Comment