获取资源路径（classes根路径）

@param resource 资源
@return 资源路径
14062
public static String getResourcePath(String resource) {
		String path = null;
		ClassLoader[] loaders = getClassLoaders(null);
		for (int i = 0; i < loaders.length; i++) {
			if (loaders[i] != null) {
				try {
					path = loaders[i].getResource(resource).getPath();
					if (StringUtils.isNotBlank(path)) {
						return path;
					}
				} catch (NullPointerException e) {

				}
			}
		}
		return path;
	}
788775
@Nullable
    public static InputStream getResourceAsStream(@NotNull String resource) {
        final ClassLoader classLoader = FileUtils.class.getClassLoader();
        final InputStream inputStream = classLoader != null
                ? classLoader.getResourceAsStream(resource)
                : ClassLoader.getSystemResourceAsStream(resource);

        if (inputStream == null) {
            try {
                return new FileInputStream(resource);
            } catch (final FileNotFoundException e) {
                LOGGER.error("Unable to create an Input Stream for " + resource, e);
            }
        }
        return inputStream;
    }
1271957
public static Resource getGenericResource(String resource) {
        log.trace("retrieving resource -> " + resource);
        try {

            final File file = normFile(resource);
            if (file.exists()) {
                return new ResourceImpl(file.toURI().toURL());
            }

            if (resource.startsWith("/")) {
                throw new IllegalArgumentException("Classpath resource cannot start with '/': " + resource);
            }
            if (resource.indexOf('\\') != -1) {
                throw new IllegalArgumentException("Classpath resource cannot contain '\\': " + resource);
            }
            URL url = getLoader().getResource(resource);
            if (url == null) {
                return null;
            }
            return new ResourceImpl(url);
        } catch (Exception e) {
            log.error("Could not retrieve resource: " + e.getMessage(), e);
            return null;
        }
    }
891172
protected List<String> findAvailableLocales(String resource) {
		List<String> availableLocales = cachedAvailableLocalePerResource.get(resource);
		if (availableLocales == null) {
			availableLocales = LocaleUtils.getAvailableLocaleSuffixesForBundle(resource);
			cachedAvailableLocalePerResource.put(resource, availableLocales);
		}

		return availableLocales;
	}
510018
protected Reader createResourceReader(Resource resource) {
        try {
            return new InputStreamReader(resource.getInputStream());
        }
        catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
168084
protected String determineResourceName(final Resource resource) {
        String resourceName = null;

        if (resource instanceof ContextResource) {
            resourceName = ((ContextResource) resource).getPathWithinContext();

        } else if (resource instanceof ByteArrayResource) {
            resourceName = resource.getDescription();

        } else {
            try {
                resourceName = resource.getFile().getAbsolutePath();
            } catch (IOException e) {
                resourceName = resource.getFilename();
            }
        }
        return resourceName;
    }
1023309
public static byte[] readByteArrayFromResource(String resource) throws IOException {
        InputStream in = getResourceAsStream(resource);
        if (in == null) {
            return null;
        }

        try {
            return readByteArray(in);
        } finally {
            closeQuietly(in);
        }
    }
1242285
public static Buffer readResourceToBuffer(@NotNull Class<?> clazz, @NotNull String resource) {
        try {
            Buffer buffer = Buffer.buffer(0);

            try (InputStream in = clazz.getResourceAsStream(resource)) {
                int read;
                byte[] data = new byte[4096];
                while ((read = in.read(data, 0, data.length)) != -1) {
                    if (read == data.length) {
                        buffer.appendBytes(data);
                    } else {
                        byte[] slice = new byte[read];
                        System.arraycopy(data, 0, slice, 0, slice.length);
                        buffer.appendBytes(slice);
                    }
                }
            }

            return buffer;
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
932992
public Object newInstance(String resource) {
        try {
            String name = resource.startsWith("/") ? resource : "/" + resource;
            File file = new File(this.getClass().getResource(name).toURI());
            return newInstance(classLoader.parseClass(new GroovyCodeSource(file), true));
        } catch (Exception e) {
            throw new GroovyClassInstantiationFailed(classLoader, resource, e);
        }
    }
1114037
public static MimeType getMimeType(Resource resource) {
        MimeType result = null;
        if (resource != null) {
            ResourceHandle handle = ResourceHandle.use(resource);
            result = getMimeType(handle.getProperty(ResourceUtil.PROP_MIME_TYPE, ""));
            if (result == null) {
                String name = resource.getName();
                if (ResourceUtil.CONTENT_NODE.equals(name)) {
                    result = getParentMimeType(resource);
                } else {
                    result = getContentMimeType(resource);
                    if (result == null) {
                        String filename = getResourceName(resource);
                        result = getMimeType(filename);
                    }
                }
            }
        }
        return result;
    }
1093302
public static Properties readPropertiesFromClassLoader(String resource) {
        Properties properties = new Properties();
        try {
            properties.load(FsCrawlerUtil.class.getClassLoader().getResourceAsStream(resource));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return properties;
    }
910696
public static List<String> readConfigIntoLines(final String resource) throws IOException {
		BufferedReader br = null;
		try {
			br = ResourceLoader.getConfigBufferedReader(resource);
			return doReadIntoLines(br);
		} finally {
			IOUtils.closeQuietly(br);
		}
	}
1057445
public static String getResourceName(Resource resource) {
        String result = null;
        if (resource != null) {
            String name = resource.getName();
            if (ResourceUtil.CONTENT_NODE.equals(name)) {
                result = getResourceName(resource.getParent());
            } else {
                result = name;
            }
        }
        return result;
    }
1067269
@Override
	public LinkRelation getItemResourceRelFor(Class<?> resource) {

		LookupContext context = LookupContext.forItemResourceRelLookup(entityType);

		return providers.getRequiredPluginFor(context).getItemResourceRelFor(resource);
	}
90607
private Reader getResourceReader(String resource) throws ResourceNotFoundException {
		List<Class<?>> excluded = new ArrayList<>();
		excluded.add(ILessCssResourceGenerator.class);
		return rsReaderHandler.getResource(bundle, resource, false, excluded);
	}
709653
public static InputStream getResourceAsStream(String resource) {
        InputStream in = ClassUtils.getContextClassLoader().getResourceAsStream(resource);
        if (in == null) {
            in = IOUtils.class.getResourceAsStream(resource);
        }

        return in;
    }
891554
public static URL getResource(String resource, Class<?> context, boolean checkParent)
    {
        URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
        if (url != null)
            return url;

        if (context != null)
        {
            ClassLoader loader = context.getClassLoader();
            while (loader != null)
            {
                url = loader.getResource(resource);
                if (url != null)
                    return url;
                loader = checkParent ? loader.getParent() : null;
            }
        }

        return ClassLoader.getSystemResource(resource);
    }