use of com.revolsys.spring.resource.GzipResource in project com.revolsys.open by revolsys.
the class IoFactory method getZipResource.
default Resource getZipResource(final Object source) {
Resource resource = Resource.getResource(source);
if (isReadFromZipFileSupported()) {
final String filename = resource.getFilename();
if (filename.endsWith(".zip")) {
final String baseName = filename.substring(0, filename.length() - 4);
final String url = "jar:" + resource.getUri() + "!/" + baseName;
final UrlResource urlResource = new UrlResource(url);
if (urlResource.exists()) {
resource = urlResource;
} else {
return null;
}
} else if (filename.endsWith(".gz")) {
return new GzipResource(resource);
} else if (filename.endsWith(getFileExtensions().get(0) + "z")) {
return new GzipResource(resource);
}
}
return resource;
}
Aggregations