org.eclipse.rdf4j.common.io

## Class ResourceUtil

- java.lang.Object
- - org.eclipse.rdf4j.common.io.ResourceUtil

-     public class ResourceUtil
      extends Object

  ResourceUtil is a utility class for retrieving resources (images, property-files, etc) from the classpath.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResourceUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static BufferedImage` | `getImage(String resourceName)` Retrieve an image resource
    `static ImageIcon` | `getImageIcon(String resourceName)` Retrieve an image icon resource.
    `static InputStream` | `getInputStream(String resourceName)` Get an inputstream on the specified resource.
    `static Properties` | `getProperties(String resourceName)` Retrieve a properties resource.
    `static String` | `getString(String resourceName)` Retrieve the String contents of the specified resource, obtained by opening in inputstream on the resource and then interpreting the bytes contained in the inputstream as if they represented characters.
    `static URL` | `getURL(String resourceName)` The URL to the specified resource
    `static Set<URL>` | `getURLs(String resourceName)` Get the URLs for a resource name using the class loaders of the current thread and of the caller.
    `static void` | `resourceToFile(String resourceName, File output)` Store a resource to a file on the file system.

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

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

- - ### Constructor Detail

    - #### ResourceUtil

          public ResourceUtil()

  - ### Method Detail

    - #### getURL

          public static URL getURL(String resourceName)

      The URL to the specified resource
      Parameters:
        `resourceName` - the name of the resource
      Returns:
        the URL to the specified resource, or null if the resource could not be found

    - #### getURLs

          public static Set<URL> getURLs(String resourceName)
                                  throws IOException

      Get the URLs for a resource name using the class loaders of the current thread and of the caller.
      Parameters:
        `resourceName` -
      Returns:
        set of URLs
      Throws:
        `IOException`

    - #### getInputStream

          public static InputStream getInputStream(String resourceName)

      Get an inputstream on the specified resource.
      Parameters:
        `resourceName` - the name of the resource
      Returns:
        an inputstream on the specified resource, or null if the resource could not be found

    - #### getString

          public static String getString(String resourceName)
                                  throws IOException

      Retrieve the String contents of the specified resource, obtained by opening in inputstream on the resource and then interpreting the bytes contained in the inputstream as if they represented characters. This may not make sense on all resources. There is no "magic" in this method to read anything other than plain text.
      Parameters:
        `resourceName` - the name of the resource
      Returns:
        the String contents of the specified resource, or null if the specified resource could not be found
      Throws:
        `IOException` - when something goes wrong trying to read the resource

    - #### getImageIcon

          public static ImageIcon getImageIcon(String resourceName)

      Retrieve an image icon resource.
      Parameters:
        `resourceName` - the name of the resource
      Returns:
        an image icon, or null if the specified resource could not be found

    - #### getImage

          public static BufferedImage getImage(String resourceName)

      Retrieve an image resource
      Parameters:
        `resourceName` - the name of the resource
      Returns:
        an image, or null if the specified resource could not be found

    - #### getProperties

          public static Properties getProperties(String resourceName)
                                          throws IOException

      Retrieve a properties resource.
      Parameters:
        `resourceName` - the name of the resource
      Returns:
        a Properties object representing the contents of the resource, or null if the specified resource could not be found
      Throws:
        `IOException`

    - #### resourceToFile

          public static void resourceToFile(String resourceName,
                                            File output)
                                     throws IOException

      Store a resource to a file on the file system.
      Parameters:
        `resourceName` - the name of the resource
        `output` - the file to write to
      Throws:
        `IOException` - if there was a problem reading the resource or writing to the file

Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.