Class Resources

java.lang.Object
org.openxava.util.Resources

public class Resources extends Object
Author:
Javier Paniza
  • Constructor Details

    • Resources

      public Resources()
  • Method Details

    • loadAsString

      public static String loadAsString(Class baseClass, String resourceName) throws IOException
      Load a resource from the classpath and return it in String format.

      Parameters:
      baseClass - Base class from start the search of resource.
      resourceName -
      Throws:
      IOException
    • loadAsString

      public static String loadAsString(String fileName) throws IOException
      Load a resource from the file system and return it in String format.

      Throws:
      IOException
    • getAsStreamInPrefixes

      public static InputStream getAsStreamInPrefixes(String resourceName, String... prefixes)
      Load the resource as a stream from classpath, looking for all path prefixes until find it in one. For example, the next code:
      Resources.getAsStreamInPrefixes("Customer.jrxml", "/reports/", "/informes/", "/") Look for /reports/Customer.jrxml, if not found for /informes/Customer.jrmxl, if not found for /Customer.jrxml.
      Parameters:
      resourceName - The name of the resource in classpath, a file name.
      prefixes - A list of path prefixes, to look for each one.
      Returns:
      The stream to get resource content, or null if not found.
      Since:
      7.0