jsky.util
Class Resources

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

public final class Resources
extends Object

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


Field Summary
static String CONFIG_PATH
          Path to config files, within the resources area.
static String CONFIG_SUBPATH
          Subpath to config files, within the resources area.
static String IMAGES_PATH
          Path to images, within the resources area.
static String IMAGES_SUBPATH
          Subpath to images, within the resources area.
static String RESOURCE_PATH
          Base path to resources.
 
Method Summary
static Icon getIcon(String iconFileName)
          Returns an Icon from the specified filename.
static Properties getProperties(String fileName)
          Loads an installed Properties file.
static URL getResource(String resource)
          Gets a URL associated with the given resource.
static InputStream getResourceAsStream(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 String RESOURCE_PATH
Base path to resources.

See Also:
Constant Field Values

IMAGES_SUBPATH

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

See Also:
Constant Field Values

IMAGES_PATH

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

See Also:
Constant Field Values

CONFIG_SUBPATH

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

See Also:
Constant Field Values

CONFIG_PATH

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

See Also:
Constant Field Values
Method Detail

getResource

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

Returns:
a URL pointing to the file, null otherwise

getResourceAsStream

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

Returns:
a InputStream for the resource else null.

getIcon

public static Icon getIcon(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 Properties getProperties(String fileName)
                                throws 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:
IOException


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.