Java Resource Load getResourceAsStream(Class clazz, String resourceName)

Here you can find the source of getResourceAsStream(Class clazz, String resourceName)

Description

get Resource As Stream

License

Open Source License

Declaration

public static InputStream getResourceAsStream(Class<?> clazz, String resourceName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.InputStream;

public class Main {
    public static InputStream getResourceAsStream(Class<?> clazz, String resourceName) {
        return clazz.getResourceAsStream(resourceName);
    }//from   ww  w  .  j  a va  2s.  c  o  m

    public static InputStream getResourceAsStream(Class<?> clazz, File file) {
        return getResourceAsStream(clazz, toResourceName(file));
    }

    public static String toResourceName(File file) {
        return toResourceName(file.getPath());
    }

    public static String toResourceName(String name) {
        return name.replaceAll("\\\\", "/");
    }
}

Related

  1. getResourceAsStream(Class clazz, String name)
  2. getResourceAsStream(Class clazz, String resource)
  3. getResourceAsStream(Class clazz, String resource, boolean checkThreadContextFirst)
  4. getResourceAsStream(Class clazz, String fileName)
  5. getResourceAsStream(Class clazz, String resource)
  6. getResourceAsStream(Class testClass, String resource)
  7. getResourceAsStream(final String fileName, ClassLoader classLoader)
  8. getResourceAsStream(final String name)
  9. getResourceAsStream(final String resourceName, final Class caller)