package org.newdawn.util; import java.io.BufferedInputStream; import java.io.InputStream; import java.net.URL; /** * A simple wrapper around resource loading should anyone decide to change * their minds how this is meant to work in the future. * * @author Kevin Glass */ public class ResourceLoader { /** * Get a resource from the classpath based * * @param ref The reference to the resource to retrieve * @return A stream from which the resource can be read */ public static InputStream getResourceAsStream(String ref) { InputStream in = ResourceLoader.class.getClassLoader().getResourceAsStream(ref); if (in == null) { Log.log("Resource not found: "+ref); System.exit(0); } return new BufferedInputStream(in); } /** * Get a resource from the classpath based * * @param ref The reference to the resource to retrieve * @return The URL the resource can be read from */ public static URL getResource(String ref) { URL in = ResourceLoader.class.getClassLoader().getResource(ref); if (in == null) { Log.log("Resource not found: "+ref); System.exit(0); } return in; } }