org.crosswire.common.util

## Class ResourceUtil

- java.lang.Object
- - org.crosswire.common.util.ResourceUtil

-     public final class ResourceUtil
      extends Object

  Better implementations of the getResource methods with less ambiguity and that are less dependent on the specific class loader situation.
  Author:
    Joe Walker, DM Smith
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `ResourceUtil()` Prevent Instantiation

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> PropertyMap` | `getProperties(Class<T> clazz)` Get and load a properties file from the writable area or if that fails from the classpath (where a default ought to be stored)
    `private static <T> PropertyMap` | `getProperties(Class<T> clazz, String subject)` Get and load a properties file from the writable area or if that fails from the classpath (where a default ought to be stored)
    `static PropertyMap` | `getProperties(String subject)` Get and load a properties file from the writable area or if that fails from the classpath (where a default ought to be stored)
    `static <T> URL` | `getResource(Class<T> clazz, String resourceName)` Generic resource URL fetcher.
    `static URL` | `getResource(String search)` Generic resource URL fetcher.
    `static <T> InputStream` | `getResourceAsStream(Class<T> clazz, String search)` Generic resource URL fetcher
    `static InputStream` | `getResourceAsStream(String search)` Generic resource URL fetcher

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ResourceUtil

          private ResourceUtil()

      Prevent Instantiation

  - ### Method Detail

    - #### getResource

          public static URL getResource(String search)
                                 throws MissingResourceException

      Generic resource URL fetcher. One way or the other we'll find it! Either as a relative or an absolute reference.
      Parameters:
        `search` - The name of the resource (without a leading /) to find
      Returns:
        The requested resource
      Throws:
        `MissingResourceException` - if the resource can not be found

    - #### getResource

          public static <T> URL getResource(Class<T> clazz,
                            String resourceName)
                                 throws MissingResourceException

      Generic resource URL fetcher. One way or the other we'll find it! Either as a relative or an absolute reference.
      Type Parameters:
        `T` - the type of the resource
      Parameters:
        `clazz` - the basis to search for the resource first.
        `resourceName` - The resource to find
      Returns:
        The requested resource
      Throws:
        `MissingResourceException` - if the resource can not be found

    - #### getResourceAsStream

          public static InputStream getResourceAsStream(String search)
                                                 throws IOException,
                                                        MissingResourceException

      Generic resource URL fetcher
      Parameters:
        `search` - The name of the resource (without a leading /) to find
      Returns:
        The requested resource
      Throws:
        `IOException` - if there is a problem reading the file
        `MissingResourceException` - if the resource can not be found

    - #### getResourceAsStream

          public static <T> InputStream getResourceAsStream(Class<T> clazz,
                                            String search)
                                                 throws IOException,
                                                        MissingResourceException

      Generic resource URL fetcher
      Type Parameters:
        `T` - the type of the resource
      Parameters:
        `clazz` - the basis to search for the resource first.
        `search` - The name of the resource (without a leading /) to find
      Returns:
        The requested resource
      Throws:
        `IOException` - if there is a problem reading the file
        `MissingResourceException` - if the resource can not be found

    - #### getProperties

          public static PropertyMap getProperties(String subject)
                                           throws IOException

      Get and load a properties file from the writable area or if that fails from the classpath (where a default ought to be stored)
      Parameters:
        `subject` - The name of the desired resource (without any extension)
      Returns:
        The found and loaded properties file
      Throws:
        `IOException` - if the resource can not be loaded

    - #### getProperties

          public static <T> PropertyMap getProperties(Class<T> clazz)
                                           throws IOException

      Get and load a properties file from the writable area or if that fails from the classpath (where a default ought to be stored)
      Type Parameters:
        `T` - the type of the resource
      Parameters:
        `clazz` - The name of the desired resource
      Returns:
        The found and loaded properties file
      Throws:
        `IOException` - if the resource can not be loaded

    - #### getProperties

          private static <T> PropertyMap getProperties(Class<T> clazz,
                                      String subject)
                                            throws IOException

      Get and load a properties file from the writable area or if that fails from the classpath (where a default ought to be stored)
      Type Parameters:
        `T` - the type of the resource
      Parameters:
        `clazz` - The name of the desired resource
        `subject` - The name of the desired resource (without any extension)
      Returns:
        The found and loaded properties file
      Throws:
        `IOException` - if the resource can not be loaded