Java Resource Load getResourceAsStream(String filePath)

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

Description

get Resource As Stream

License

Apache License

Declaration

public static InputStream getResourceAsStream(String filePath) throws FileNotFoundException 

Method Source Code

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

import java.io.File;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.InputStream;

public class Main {
    public static InputStream getResourceAsStream(String filePath) throws FileNotFoundException {
        Thread.currentThread().getContextClassLoader();
        InputStream inputstream = ClassLoader.getSystemResourceAsStream(filePath);
        if (inputstream == null) {
            inputstream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
        }/*from  w  ww  .  j  a v  a 2  s .  co  m*/
        if (inputstream == null) {
            inputstream = new FileInputStream(new File(filePath));
        }
        return inputstream;
    }
}

Related

  1. getResourceAsStream(final String resourceName, final Class caller)
  2. getResourceAsStream(Object context, String resourceName)
  3. getResourceAsStream(Object o, String resource)
  4. getResourceAsStream(String filename)
  5. getResourceAsStream(String filename)
  6. getResourceAsStream(String name)
  7. getResourceAsStream(String name)
  8. getResourceAsStream(String name)
  9. getResourceAsStream(String name)