Here you can find the source of getResource(String name)
Parameter | Description |
---|---|
name | Resource Name |
public static URL getResource(String name)
//package com.java2s; //License from project: Apache License import java.net.URL; public class Main { /**//from w w w . j a v a 2s . com * @param name Resource Name * @return Resource URL */ public static URL getResource(String name) { ClassLoader cl = getClassLoader(); if (cl == null) { return null; } return cl.getResource(name); } private static ClassLoader getClassLoader() { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { return ClassLoader.getSystemClassLoader(); } return cl; } }