Java Resource Load getResourceAsStream(Class baseclass, String name)

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

Description

E.g.

License

Open Source License

Parameter

Parameter Description
baseclass determines the package where to seek for resource.
name of the resource.

Declaration

public static final InputStream getResourceAsStream(Class baseclass, String name) 

Method Source Code

//package com.java2s;
/*/*from   w w w.j av a2 s. c  om*/
 * Copyright 2001-2008 Aqris Software AS. All rights reserved.
 * 
 * This program is dual-licensed under both the Common Development
 * and Distribution License ("CDDL") and the GNU General Public
 * License ("GPL"). You may elect to use one or the other of these
 * licenses.
 */

import java.io.InputStream;

public class Main {
    /**
     * E.g. if baseclass is <code>a.b.c</code>, then it will seek for:<br>
     * /a/b/resources/&lt;name&gt;.properties<br>
     * and return it as stream
     *
     * @param baseclass determines the package where to seek for resource.
     * @param name of the resource.
     *
     * @return {@link InputStream}
     */
    public static final InputStream getResourceAsStream(Class baseclass, String name) {
        return baseclass.getResourceAsStream("resources/" + name + ".properties");
    }
}

Related

  1. getResourceAsInputStream(Class resourceClass, String resourceName)
  2. getResourceAsProperties(String resource)
  3. getResourceAsReader(final Class classLocation, final String resourceName)
  4. getResourceAsReader(String name)
  5. getResourceAsReader(String relativeName, Class clazz, String enc)
  6. getResourceAsStream(Class claz, String name)
  7. getResourceAsStream(Class clazz, String name)
  8. getResourceAsStream(Class clazz, String resource)
  9. getResourceAsStream(Class clazz, String resource, boolean checkThreadContextFirst)