Java Resource Load getResourceAsInputStream(Class resourceClass, String resourceName)

Here you can find the source of getResourceAsInputStream(Class resourceClass, String resourceName)

Description

get Resource As Input Stream

License

Apache License

Declaration

public static InputStream getResourceAsInputStream(Class<?> resourceClass, String resourceName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.InputStream;

public class Main {
    public static InputStream getResourceAsInputStream(Class<?> resourceClass, String resourceName) {
        InputStream inputStream = resourceClass.getResourceAsStream(resourceName);
        if (inputStream == null) {
            throw new IllegalStateException("Unable to find resource [" + resourceName + "] relative to class ["
                    + resourceClass.getName() + "].");
        }/* w  ww  .ja va  2 s.  c  o  m*/
        return inputStream;
    }
}

Related

  1. getResourceAsBytes(String url)
  2. getResourceAsFile(String path)
  3. getResourceAsFile(String resourceName)
  4. getResourceAsFile(String resourcePath)
  5. getResourceAsFile(T testSuite, String resourceName)
  6. getResourceAsProperties(String resource)
  7. getResourceAsReader(final Class classLocation, final String resourceName)
  8. getResourceAsReader(String name)
  9. getResourceAsReader(String relativeName, Class clazz, String enc)