Returns a resource on the classpath as a Properties object

@param loader
The classloader used to load the resource
@param resource
The resource to find
@throws IOException
If the resource cannot be found or read
@return The resource
189621
public static Properties getResourceAsProperties(ClassLoader loader, String resource) throws IOException {
        Properties props = new Properties();
        InputStream in = null;
        String propfile = resource;
        in = getResourceAsStream(loader, propfile);
        props.load(in);
        in.close();
        return props;
    }
90607
private Reader getResourceReader(String resource) throws ResourceNotFoundException {
		List<Class<?>> excluded = new ArrayList<>();
		excluded.add(ILessCssResourceGenerator.class);
		return rsReaderHandler.getResource(bundle, resource, false, excluded);
	}
329161
public static InputStream getInputStream(final File resource) throws IOException {
		if (resource.exists()) {
			return new FileInputStream(resource);
		}
		LOG.info("Could not find file '" + resource.getAbsolutePath() + "' in the file system. Trying to load it from the classpath...");

		String path = FilenameUtils.separatorsToUnix(resource.getPath());
		ClassLoader cl = Thread.currentThread().getContextClassLoader();

		InputStream is = cl.getResourceAsStream(path);

		if (is == null) {
			if (path.startsWith("/")) {
				LOG.info("Could not find file '" + resource
						+ " in the file system. Trying to load it from the classpath without the leading slash...");
				is = cl.getResourceAsStream(path.substring(1));
			}

			if (is == null) {
				// If configs are to be loaded from the classpath, we also try it directly
				// stripping of the config directory
				String configDir = new File(getConfigDir()).getName();
				if (path.startsWith(configDir)) {
					is = cl.getResourceAsStream(StringUtils.substringAfter(path, configDir + '/'));
				}
			}

			if (is == null) {
				throw new FileNotFoundException("Could not load file '" + resource + "'");
			}
		}

		return is;
	}
308539
static String readResource(String name) throws IOException {
        // Attempt to find the file as a resource
        String spec = String.format(BUILTIN_FILE_PATH_FORMAT, name);

        try (InputStream in = JShellTool.class.getResourceAsStream(spec);
                BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
            return reader.lines().collect(Collectors.joining("\n", "", "\n"));
        }
    }
862557
private static List<String> loadClasspathResource(String resource, ResourceLoader resourceLoader, String resourcePaths) throws IOException{
        List<String> result = new ArrayList<>();
        LOGGER.info("类路径资源："+resource);
        Enumeration<URL> ps = AutoDetector.class.getClassLoader().getResources(resource);
        while(ps.hasMoreElements()) {
            URL url=ps.nextElement();
            LOGGER.info("类路径资源URL："+url);
            if(url.getFile().contains(".jar!")){
                //加载jar资源
                result.addAll(load("classpath:"+resource));
                continue;
            }
            File file=new File(url.getFile());
            boolean dir = file.isDirectory();
            if(dir){
                //处理目录
                result.addAll(loadAndWatchDir(file.toPath(), resourceLoader, resourcePaths));
            }else{
                //处理文件
                result.addAll(load(file.getAbsolutePath()));
                //监控文件
                watchFile(file, resourceLoader, resourcePaths);
            }
        }
        return result;
    }
323762
public URL getResource(String name) {
        for (int i = 0; i < classLoaders.length; i++) {
            URL url = classLoaders[i].getResource(name);
            if (url != null) {
                return url;
            }
        }
        if (getParent() != null) {
            return super.getResource(name);
        } else {
            return null;
        }
    }
793230
public static Provider resourceProvider(String pathToResource, Charset encoding) throws IOException {
        ClassLoader classLoader = Provider.class.getClassLoader();
        return resourceProvider(classLoader, pathToResource, encoding);
    }
472331
public InputStream getResourceAsStream(final String name) {
        for ( final ClassLoader classLoader : this.classLoaders ) {
            InputStream stream = classLoader.getResourceAsStream( name );
            if ( stream != null ) {
                return stream;
            }
        }

        return null;
    }
582381
public static Map<String, Val> loads(@NonNull Resource resource) throws IOException {
      return loads(resource.readToString());
   }
439780
public static InputStream readResource(String name) {
        String classpath = System.getProperty("java.class.path");
        LOGGER.trace("Reading {} from classpath={}", name, classpath);
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader == null) {
            throw new IllegalStateException("Can not obtain classloader instance from current thread");
        }
        return classLoader.getResourceAsStream(name);
    }
526930
public static InputStreamReader getInputStreamReader(final File resource, final String encoding) throws IOException {
		return new InputStreamReader(getInputStream(resource), encoding);
	}
329040
public static SeLionDataProvider getDataProvider(DataResource resource)
            throws IOException {
        logger.entering(resource);

        if(resource == null) {
            return null;
        }

        switch (resource.getType().toUpperCase()) {
        case "XML":
            return new XmlDataProviderImpl((XmlDataSource) resource);
        case "JSON":
            return new JsonDataProviderImpl(resource);
        case "YAML":
        case "YML":
            return new YamlDataProviderImpl(resource);
        case "XLSX":
        case "XLS":
            return new ExcelDataProviderImpl(resource);
        default:
            return null;
        }
     }
476986
public static List<URL> getClasspathURLs(ClassLoader loader) {
        List<URL> urls = Lists.newArrayList();
        if (loader != null) {
            final Enumeration<URL> resources;
            try {
                resources = loader.getResources("");
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            while (resources.hasMoreElements()) {
                URL location = resources.nextElement();
                urls.add(location);
            }
        }
        return urls;
    }
1333553
@Override
  public ResourceStorageLoadable getOrCreateResourceStorageLoadable(final StorageAwareResource resource) {
    try {
      final ResourceStorageProviderAdapter stateProvider = IterableExtensions.<ResourceStorageProviderAdapter>head(Iterables.<ResourceStorageProviderAdapter>filter(resource.getResourceSet().eAdapters(), ResourceStorageProviderAdapter.class));
      if ((stateProvider != null)) {
        final ResourceStorageLoadable inputStream = stateProvider.getResourceStorageLoadable(resource);
        if ((inputStream != null)) {
          return inputStream;
        }
      }
      InputStream _xifexpression = null;
      boolean _exists = resource.getResourceSet().getURIConverter().exists(this.getBinaryStorageURI(resource.getURI()), CollectionLiterals.<Object, Object>emptyMap());
      if (_exists) {
        _xifexpression = resource.getResourceSet().getURIConverter().createInputStream(this.getBinaryStorageURI(resource.getURI()));
      } else {
        InputStream _xblockexpression = null;
        {
          final AbstractFileSystemAccess2 fsa = this.getFileSystemAccess(resource);
          final String outputRelativePath = this.computeOutputPath(resource);
          _xblockexpression = fsa.readBinaryFile(outputRelativePath);
        }
        _xifexpression = _xblockexpression;
      }
      final InputStream inputStream_1 = _xifexpression;
      return this.createResourceStorageLoadable(inputStream_1);
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  }
1107389
public static final Properties read(String classpath) throws IOException{
        final URL url = Resources.getResource(classpath);
        final ByteSource byteSource = Resources.asByteSource(url);
        final Properties properties = new Properties();
        InputStream inputStream = null;
        try {
            inputStream = byteSource.openBufferedStream();
            properties.load(inputStream);
        } catch (final IOException ioException) {
            ioException.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (final IOException ioException) {
                    throw ioException;
                }
            }
        }
        return properties;
    }
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;
    }
29338
public static RefCapablePropertyResourceBundle
            getBundle(String baseName, Locale locale, ClassLoader loader) {
        return getRef(baseName,
                ResourceBundle.getBundle(baseName, locale, loader), loader);
    }