jsky.util
Class Resources

java.lang.Object
  extended by jsky.util.Resources

public final class Resources
extends java.lang.Object

Resources provides a central class with methods for accessing project resources.


Field Summary
static java.lang.String CONFIG_PATH
          Path to config files, within the resources area.
static java.lang.String CONFIG_SUBPATH
          Subpath to config files, within the resources area.
static java.lang.String IMAGES_PATH
          Path to images, within the resources area.
static java.lang.String IMAGES_SUBPATH
          Subpath to images, within the resources area.
static java.lang.String RESOURCE_PATH
          Base path to resources.
 
Method Summary
static javax.swing.Icon getIcon(java.lang.String iconFileName)
          Returns an Icon from the specified filename.
static java.util.Properties getProperties(java.lang.String fileName)
          Loads an installed Properties file.
static java.net.URL getResource(java.lang.String resource)
          Gets a URL associated with the given resource.
static java.io.InputStream getResourceAsStream(java.lang.String resource)
          Gets a resource as an InputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_PATH

public static final java.lang.String RESOURCE_PATH
Base path to resources.

See Also:
Constant Field Values

IMAGES_SUBPATH

public static final java.lang.String IMAGES_SUBPATH
Subpath to images, within the resources area.

See Also:
Constant Field Values

IMAGES_PATH

public static final java.lang.String IMAGES_PATH
Path to images, within the resources area.

See Also:
Constant Field Values

CONFIG_SUBPATH

public static final java.lang.String CONFIG_SUBPATH
Subpath to config files, within the resources area.

See Also:
Constant Field Values

CONFIG_PATH

public static final java.lang.String CONFIG_PATH
Path to config files, within the resources area.

See Also:
Constant Field Values
Method Detail

getResource

public static java.net.URL getResource(java.lang.String resource)
Gets a URL associated with the given resource.

Returns:
a URL pointing to the file, null otherwise

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String resource)
Gets a resource as an InputStream.

Returns:
a InputStream for the resource else null.

getIcon

public static javax.swing.Icon getIcon(java.lang.String iconFileName)
Returns an Icon from the specified filename.

Parameters:
iconFileName - The relative path name to the image file. For example, "flag.gif". It is assumed the image file is being properly installed to the resources directory.
Returns:
Icon constructed from data in iconFileName. Even though the method interface can't guarentee this, the icon implementation will be Serializable. Returns null (does not throw an Exception) if specified resource is not found.

getProperties

public static java.util.Properties getProperties(java.lang.String fileName)
                                          throws java.io.IOException
Loads an installed Properties file.

Parameters:
fileName - relative path to the configuration file (which must be loadable by the java.util.Properties class)
Returns:
a Properties object created from the configuration file; null if the file does not exist
Throws:
java.io.IOException