Java Resource Load getResourceAsStream(String name, Class clzz)

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

Description

get Resource As Stream

License

Open Source License

Declaration

public static InputStream getResourceAsStream(String name, Class<?> clzz) 

Method Source Code


//package com.java2s;
/*/* w w  w .  ja  va2s  . c  o  m*/
 * Copyright 2011-2016 ZXC.com All right reserved. This software is the confidential and proprietary information of
 * ZXC.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into with ZXC.com.
 */

import java.io.InputStream;

public class Main {
    public static InputStream getResourceAsStream(String name, Class<?> clzz) {
        InputStream inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
        if (inStream != null) {
            return inStream;
        }
        ClassLoader c = clzz.getClassLoader();
        if (c != null) {
            inStream = c.getResourceAsStream(name);
            if (inStream != null) {
                return inStream;
            }
        }
        return ClassLoader.getSystemResourceAsStream(name);
    }
}

Related

  1. getResourceAsStream(String name)
  2. getResourceAsStream(String name)
  3. getResourceAsStream(String name, Class aClass)
  4. getResourceAsStream(String name, Class clazz)
  5. getResourceAsStream(String name, Class clazz)
  6. getResourceAsStream(String path)
  7. getResourceAsStream(String path, Class caller)
  8. getResourceAsStream(String path, ClassLoader cl)
  9. getResourceAsStream(String path, ClassLoader loader)