Changeset 15416 in josm for trunk/src/org/openstreetmap/josm/io/CachedFile.java
- Timestamp:
- 2019-10-05T00:50:17+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r15329 r15416 24 24 import java.util.List; 25 25 import java.util.Map; 26 import java.util.Optional; 26 27 import java.util.concurrent.ConcurrentHashMap; 27 28 import java.util.concurrent.TimeUnit; … … 35 36 import org.openstreetmap.josm.tools.Pair; 36 37 import org.openstreetmap.josm.tools.PlatformManager; 38 import org.openstreetmap.josm.tools.ResourceProvider; 37 39 import org.openstreetmap.josm.tools.Utils; 38 40 … … 41 43 * 42 44 * Supports URLs, local files, and a custom scheme (<code>resource:</code>) to get 43 * resources from the current *.jar file. (Local caching is only done for URLs.) 45 * resources from the current JOSM *.jar file as well as plugins *.jar files. 46 * (Local caching is only done for URLs.) 44 47 * <p> 45 48 * The mirrored file is only downloaded if it has been more than 7 days since … … 225 228 if (file == null) { 226 229 if (name != null && name.startsWith("resource://")) { 227 String resourceName = name.substring("resource:/".length()); 228 InputStream is = Utils.getResourceAsStream(getClass(), resourceName); 229 if (is == null) { 230 throw new IOException(tr("Failed to open input stream for resource ''{0}''", name)); 231 } 232 return is; 230 return Optional.ofNullable(ResourceProvider.getResourceAsStream(name.substring("resource:/".length()))) 231 .orElseThrow(() -> new IOException(tr("Failed to open input stream for resource ''{0}''", name))); 233 232 } else { 234 233 throw new IOException("No file found for: "+name);
Note:
See TracChangeset
for help on using the changeset viewer.
