Create a reader for the specified resource.

@param resource resource to create reader for

@return reader for the specified resource
510018
protected Reader createResourceReader(Resource resource) {
        try {
            return new InputStreamReader(resource.getInputStream());
        }
        catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
26997
public static File getResourceAsFile(final String resource) {
        final ClassLoader classLoader = FileUtils.class.getClassLoader();
        final String path = classLoader != null
                ? classLoader.getResource(resource).getFile()
                : ClassLoader.getSystemResource(resource).getFile();

        if (path == null) {
            return new File(resource);
        }
        return new File(path);
    }
689619
public ResourceMetaData getResourceMetaData(Resource resource)
    {
        Object o=resource.getAssociate();
        if (o instanceof ResourceMetaData)
            return (ResourceMetaData)o;
        return new ResourceMetaData(resource);
    }
1263723
@Override
    public Resource createResource(String resourceName, String libraryName) {

        return getWrapped().createResource(resourceName, libraryName);

    }
1140177
private String readResource(final String resourceName) throws IOException {
      return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(resourceName), DEFAULT_CHARSET)).lines().collect(Collectors.joining("\n"));
   }
189755
public static InputStreamReader getConfigInputStreamReader(final String resource, final String encoding) throws IOException {
		return new InputStreamReader(getConfigInputStream(resource), encoding);
	}
210849
public static X509Certificate readCertificate(final Resource resource) {
        try (val in = resource.getInputStream()) {
            return CertUtil.readCertificate(in);
        } catch (final Exception e) {
            throw new IllegalArgumentException("Error reading certificate " + resource, e);
        }
    }
598077
@Override
	public Reader getReader() throws IOException {
		// Return an Aggregation reader for all the resources in this
		// aggregated resource
		List<Reader> readers = new ArrayList<Reader>(resources.size());
		for (IResource resource : resources) {
			readers.add(resource.getReader());
		}
		return new AggregationReader(readers);
	}
1304943
public static BufferedReader getBufferedReader(final File resource, final String encoding) throws IOException {
		return new BufferedReader(getInputStreamReader(resource, encoding));
	}
1347310
public T loadXml(DataResource resource) {

    if (isXIncludeAware()) {
      XMLStreamReader streamReader = getStaxUtil().createXmlStreamReader(resource, true);
      try {
        Object unmarshalledObject = getOrCreateUnmarshaller().unmarshal(streamReader);
        T jaxbBean = this.xmlBeanClass.cast(unmarshalledObject);
        validate(jaxbBean);
        return jaxbBean;
      } catch (Exception e) {
        throw new XmlInvalidException(e, resource);
      } finally {
        try {
          streamReader.close();
        } catch (XMLStreamException e) {
          throw new IllegalStateException("Failed to close stream reader.", e);
        }
      }
    } else {
      InputStream inputStream = resource.openStream();
      try {
        return loadXml(inputStream, resource);
      } catch (RuntimeException e) {
        throw new XmlInvalidException(e, resource.getUri());
      } finally {
        try {
          inputStream.close();
        } catch (Exception e) {
          // ignore...
        }
      }
    }
  }
909054
public static InputStream getResourceAsStream(String resource) throws IOException {
    InputStream in = null;
    ClassLoader loader = ResourcesUtils.class.getClassLoader();
    if (loader != null) {
      in = loader.getResourceAsStream(resource);
    }
    if (in == null) {
      in = ClassLoader.getSystemResourceAsStream(resource);
    }
    if (in == null) {
      throw new IOException("Could not find resource " + resource);
    }
    return in;
  }
877457
@Override
	public void addResourceReader(ResourceReader rd) {

		if (rd instanceof TextResourceReader) {
			resourceReaders.add((TextResourceReader) rd);
			Collections.sort(resourceReaders, new ResourceReaderComparator(config));
		}

		if (rd instanceof StreamResourceReader) {
			streamResourceReaders.add((StreamResourceReader) rd);
			Collections.sort(streamResourceReaders, new ResourceReaderComparator(config));
		}

		initReader(rd);
	}
760734
public static Collection<URL> findResources(final String resource) {
        final Collection<UrlResource> urlResources = findUrlResources(resource);
        final Collection<URL> resources = new LinkedHashSet<>(urlResources.size());
        for (final UrlResource urlResource : urlResources) {
            resources.add(urlResource.getUrl());
        }
        return resources;
    }
1040269
public static String readURLToString(@NotNull String resource) {
        try {
            try (Reader r = new BufferedReader(new InputStreamReader(new URL(resource).openStream(), "UTF-8"))) {

                Writer writer = new StringWriter();

                char[] buffer = new char[1024];
                int n;
                while ((n = r.read(buffer)) != -1) {
                    writer.write(buffer, 0, n);
                }

                return writer.toString();
            }
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
73508
public Reader getConfResourceAsReader(String name) {
		try {
			URL url= getResource(name);

			if (url == null) {
				LOG.info(name + " not found");
				return null;
			} else {
				LOG.info("found resource " + name + " at " + url);
			}

			return new InputStreamReader(url.openStream(), Charsets.UTF_8);
		} catch (Exception e) {
			return null;
		}
	}
294207
public static String readFromResource(String resource) throws IOException {

        InputStream in = getResourceAsStream(resource);
        if (in == null) {
            return null;
        }
        try {
            return read(in);
        } finally {
            closeQuietly(in);
        }
    }
665125
public static String getResourceURL(String resource) {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        return cl.getResource(resource).toString();
    }