With a simple modification we can pass to 'org.geotools.gce.geotiff.GeoTiffFormat' even URLs as sources.
We can change the method 'public GridCoverageReader getReader(Object source)' as follow:
...
import java.net.URL;
import java.net.URLDecoder;
...
public GridCoverageReader getReader(Object source) {
if (source instanceof CatalogEntry) {
source = ((CatalogEntry) source).resource();
}
GridCoverageReader reader = null;
if (accepts(source)) {
if (source instanceof URL) {
URL url = (URL) source;
try {
final String pathname = URLDecoder.decode(url.getFile(),"UTF-8");
reader = new GeoTiffReader(this, new File(pathname), null);
} catch (Exception e) {
reader = null;
}
} else {
reader = new GeoTiffReader(this, source, null);
}
}
return reader;
}
And the method 'public boolean accepts(Object o)' as follow:
public boolean accepts(Object o) {
boolean goodfile = false;
if (o instanceof CatalogEntry) {
o = ((CatalogEntry) o).resource();
}
goodfile = o instanceof File;
if (goodfile) {
goodfile = GeoTiffReader.isGeoTiffFile((File) o);
} else if (o instanceof URL) {
URL url = (URL) o;
try {
final String pathname = URLDecoder.decode(url.getFile(),"UTF-8");
goodfile = GeoTiffReader.isGeoTiffFile(new File(pathname));
} catch (Exception e) {
goodfile = false;
}
}
return goodfile;
}