Resource r = ctx2.getResource(location); try { InputStream in = r.getInputStream(); } catch (IOException e) { r = ctx2.getResource("classpath:" + location); try { r.getInputStream().close();
@Override public Resource getResource(String location) { if (location.startsWith(CLASSPATH_URL_PREFIX)) { for(String base : resourceBases) { final FileSystemResource resource = new FileSystemResource(new File(base, location.substring(CLASSPATH_URL_PREFIX.length()))); if(resource.exists()) { return resource; } } } return super.getResource(location); } }
/** * {@inheritDoc} * * <p> * Supports wildcard classpath locations prefixed with {@link ResourcePatternResolver#CLASSPATH_ALL_URL_PREFIX}. * </p> */ @Override public Resource getResource(final String location) { Assert.notNull(location, "Location must not be null"); if (location.startsWith(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX)) { return new ClassPathResource(location.substring(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX.length()), getClassLoader()); } return super.getResource(location); }
/** * ResourceLoader * Retrieves a resource at a given location * * If the resource is not a classpath resource, then the search * path is consulted. * * If a match cannot be found, the superclass method is consulted. */ public Resource getResource(String location) { Resource resource = null; if (getSearchPath() != null) { resource = getResourceFromSearchPath(location); } else { resource = super.getResource(location); } return resource; }
/** * ResourceLoader * Retrieves a resource at a given location * * If the resource is not a classpath resource, then the search * path is consulted. * * If a match cannot be found, the superclass method is consulted. */ public Resource getResource(String location) { Resource resource = null; if (getSearchPath() != null) { resource = getResourceFromSearchPath(location); } else { resource = super.getResource(location); } return resource; }
Resource r = ctx2.getResource(location); try { InputStream in = r.getInputStream(); } catch (IOException e) { r = ctx2.getResource("classpath:" + location); try { r.getInputStream().close();
Resource r = ctx2.getResource(location); try { InputStream in = r.getInputStream(); } catch (IOException e) { r = ctx2.getResource("classpath:" + location); try { r.getInputStream().close();