Resource.java
package org.opentrafficsim.simulationengine;
import java.io.InputStream;
/**
* Resource utility.
* <p>
* Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
* BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
* <p>
* @version $Revision$, $LastChangedDate$, by $Author$, initial version 23 mei 2018 <br>
* @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
* @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
* @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
*/
public final class Resource
{
/** Constructor. */
private Resource()
{
//
}
/**
* Obtains stream for resource, either in IDE or java.
* @param name String; name of resource
* @return the resolved input stream
*/
public static InputStream getResourceAsStream(final String name)
{
InputStream stream = Resource.class.getResourceAsStream(name);
if (stream != null)
{
return stream;
}
stream = Resource.class.getResourceAsStream("/resources" + name);
if (stream != null)
{
return stream;
}
throw new RuntimeException("Unable to load resource " + name);
}
}