Java Resource Load getResourceAsStream(String name)

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

Description

Returns an input stream from a file, given its name.

License

Open Source License

Parameter

Parameter Description
name Name of the resource.

Return

File pointing to the resource.

Declaration

public static InputStream getResourceAsStream(String name) 

Method Source Code

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

import java.io.InputStream;

public class Main {
    /**/*from w  ww  .  ja  va  2 s  .  c  om*/
     * Returns an input stream from a file, given its name.
     * 
     * @param name
     *          Name of the resource.
     * @return File pointing to the resource.
     */
    public static InputStream getResourceAsStream(String name) {
        return getContextClassLoader().getResourceAsStream(name);
    }

    /**
     * Obtains the class loader of the current thread.
     * 
     * @return The class loader of the current thread.
     */
    private static ClassLoader getContextClassLoader() {
        return Thread.currentThread().getContextClassLoader();
    }
}

Related

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