package org.opentrafficsim.swing.gui; import java.io.InputStream; /** * Resource utility. *
* Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* @version $Revision$, $LastChangedDate$, by $Author$, initial version 23 mei 2018
* @author Alexander Verbraeck
* @author Peter Knoppers
* @author Wouter Schakel
*/
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);
}
}