Java Resource Load getResourceAsStream(Object o, String resource)

Here you can find the source of getResourceAsStream(Object o, String resource)

Description

get Resource As Stream

License

Open Source License

Declaration

public static InputStream getResourceAsStream(Object o, String resource) 

Method Source Code

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

import java.io.InputStream;

public class Main {
    public static InputStream getResourceAsStream(Object o, String resource) {
        String newPath = "";
        if (resource.startsWith("/")) {
            newPath = "/net/ages/alwb/utils/app/resources" + resource;
        } else {//from  ww w  .  jav a 2s .c om
            newPath = "/net/ages/alwb/utils/app/resources/" + resource;
        }
        try {
            return o.getClass().getResourceAsStream(newPath);
        } catch (Exception e) {
            return null;
        }
    }
}

Related

  1. getResourceAsStream(final String fileName, ClassLoader classLoader)
  2. getResourceAsStream(final String name)
  3. getResourceAsStream(final String resourceName, final Class caller)
  4. getResourceAsStream(final String resourceName, final Class caller)
  5. getResourceAsStream(Object context, String resourceName)
  6. getResourceAsStream(String filename)
  7. getResourceAsStream(String filename)
  8. getResourceAsStream(String filePath)
  9. getResourceAsStream(String name)