public IFile getFile(File file) { return getFile(new FileSystemResource(file).getSpringResource()); }
/** * Create resource from full path. * * @param pathWithPrefix * the full path with prefix. See all subclasses of this class * for the possible prefixes. * @return the resource or null if the prefix is not supported. */ public static PaxmlResource createFromPath(String pathWithPrefix) { if (pathWithPrefix.startsWith(FileSystemResource.PREFIX)) { return new FileSystemResource( new File(pathWithPrefix.substring(FileSystemResource.PREFIX.length()))); } else if (pathWithPrefix.startsWith(ClasspathResource.SPRING_PREFIX1)) { String barePath = pathWithPrefix.substring(ClasspathResource.SPRING_PREFIX1.length()); return new ClasspathResource(barePath); } else if (pathWithPrefix.startsWith(ClasspathResource.SPRING_PREFIX2)) { String barePath = pathWithPrefix.substring(ClasspathResource.SPRING_PREFIX2.length()); return new ClasspathResource(barePath); } else if (pathWithPrefix.startsWith("jar:")) { String barePath=StringUtils.substringAfterLast(pathWithPrefix, "!"); return new ClasspathResource(barePath); } return null; }
/** * Create resource from full path. * * @param pathWithPrefix * the full path with prefix. See all subclasses of this class * for the possible prefixes. * @return the resource or null if the prefix is not supported. */ public static PaxmlResource createFromPath(String pathWithPrefix) { if (pathWithPrefix.startsWith(FileSystemResource.PREFIX)) { return new FileSystemResource( new File(pathWithPrefix.substring(FileSystemResource.PREFIX.length()))); } else if (pathWithPrefix.startsWith(ClasspathResource.SPRING_PREFIX1)) { String barePath = pathWithPrefix.substring(ClasspathResource.SPRING_PREFIX1.length()); return new ClasspathResource(barePath); } else if (pathWithPrefix.startsWith(ClasspathResource.SPRING_PREFIX2)) { String barePath = pathWithPrefix.substring(ClasspathResource.SPRING_PREFIX2.length()); return new ClasspathResource(barePath); } else if (pathWithPrefix.startsWith("jar:")) { String barePath=StringUtils.substringAfterLast(pathWithPrefix, "!"); return new ClasspathResource(barePath); } return null; }
public static Set<PaxmlResource> findResources(String base, Set<String> includes, Set<String> excludes) { if (includes == null) { includes = new HashSet<String>(1); includes.add("**/*.*"); } if (excludes == null) { excludes = Collections.EMPTY_SET; } if (StringUtils.isEmpty(base)) { base = PaxmlUtils.getCurrentDir().getAbsolutePath(); } File f = new File(base); if (f.isDirectory()) { f = new File(f, "fake.file"); } Resource baseRes = new FileSystemResource(f).getSpringResource(); Set<PaxmlResource> include = new LinkedHashSet<PaxmlResource>(0); Set<PaxmlResource> exclude = new LinkedHashSet<PaxmlResource>(0); ResourceMatcher matcher = new ResourceMatcher(includes, excludes); for (String pattern : matcher.include) { include.addAll(ResourceLocator.findResources(pattern, baseRes)); } for (String pattern : matcher.exclude) { exclude.addAll(ResourceLocator.findResources(pattern, baseRes)); } include.removeAll(exclude); return include; }
File file = res.getFile(); if (file.isFile()) { set.add(new FileSystemResource(file));
File file = res.getFile(); if (file.isFile()) { set.add(new FileSystemResource(file));