package at.gv.egiz.moazs.util; import org.springframework.stereotype.Component; import java.io.File; @Component public class FileUtils { /** * If path is relative, try to resolve path as classpath resource. If path is absolute, * leave as-is. */ public String determinePath(String abstractPath) { if (new File(abstractPath).isAbsolute()) { return abstractPath; } else { //java.lang.Class needs relative resources to start with "/" var resource = this.getClass().getResource("/" + abstractPath); return resource == null ? abstractPath : resource.getFile(); } } }