< prev index next >

src/java.base/share/classes/jdk/internal/loader/URLClassPath.java

Print this page




1178          */
1179         static boolean isRelative(String child) {
1180             try {
1181                 return !URI.create(child).isAbsolute();
1182             } catch (IllegalArgumentException e) {
1183                 return false;
1184             }
1185         }
1186     }
1187 
1188     /*
1189      * Nested class used to represent a loader of classes and resources
1190      * from a file URL that refers to a directory.
1191      */
1192     private static class FileLoader extends Loader {
1193         /* Canonicalized File */
1194         private File dir;
1195 
1196         FileLoader(URL url) throws IOException {
1197             super(url);
1198             if (!"file".equals(url.getProtocol())) {
1199                 throw new IllegalArgumentException("url");
1200             }
1201             String path = url.getFile().replace('/', File.separatorChar);
1202             path = ParseUtil.decode(path);
1203             dir = (new File(path)).getCanonicalFile();
1204         }
1205 
1206         /*
1207          * Returns the URL for a resource with the specified name
1208          */
1209         @Override
1210         URL findResource(final String name, boolean check) {
1211             Resource rsc = getResource(name, check);
1212             if (rsc != null) {
1213                 return rsc.getURL();
1214             }
1215             return null;
1216         }
1217 
1218         @Override
1219         Resource getResource(final String name, boolean check) {
1220             final URL url;




1178          */
1179         static boolean isRelative(String child) {
1180             try {
1181                 return !URI.create(child).isAbsolute();
1182             } catch (IllegalArgumentException e) {
1183                 return false;
1184             }
1185         }
1186     }
1187 
1188     /*
1189      * Nested class used to represent a loader of classes and resources
1190      * from a file URL that refers to a directory.
1191      */
1192     private static class FileLoader extends Loader {
1193         /* Canonicalized File */
1194         private File dir;
1195 
1196         FileLoader(URL url) throws IOException {
1197             super(url);



1198             String path = url.getFile().replace('/', File.separatorChar);
1199             path = ParseUtil.decode(path);
1200             dir = (new File(path)).getCanonicalFile();
1201         }
1202 
1203         /*
1204          * Returns the URL for a resource with the specified name
1205          */
1206         @Override
1207         URL findResource(final String name, boolean check) {
1208             Resource rsc = getResource(name, check);
1209             if (rsc != null) {
1210                 return rsc.getURL();
1211             }
1212             return null;
1213         }
1214 
1215         @Override
1216         Resource getResource(final String name, boolean check) {
1217             final URL url;


< prev index next >