Java Resource Load getResourceAsStream(String name)

Here you can find the source of getResourceAsStream(String name)

Description

get Resource As Stream

License

Apache License

Parameter

Parameter Description
name Resource Name

Return

Resource Input Stream

Declaration

public static InputStream getResourceAsStream(String name) 

Method Source Code


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

import java.io.InputStream;

public class Main {
    /**//from   w w w .  j  a  v a2  s.c o  m
     * @param name Resource Name
     * @return Resource Input Stream
     */
    public static InputStream getResourceAsStream(String name) {
        ClassLoader cl = getClassLoader();

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

        return cl.getResourceAsStream(name);
    }

    private static ClassLoader getClassLoader() {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();

        if (cl == null) {
            return ClassLoader.getSystemClassLoader();
        }

        return cl;
    }
}

Related

  1. getResourceAsStream(Object o, String resource)
  2. getResourceAsStream(String filename)
  3. getResourceAsStream(String filename)
  4. getResourceAsStream(String filePath)
  5. getResourceAsStream(String name)
  6. getResourceAsStream(String name)
  7. getResourceAsStream(String name)
  8. getResourceAsStream(String name, Class aClass)
  9. getResourceAsStream(String name, Class clazz)