org.springframework.core.io.support

Class PropertiesLoaderUtils

  • java.lang.Object
    • org.springframework.core.io.support.PropertiesLoaderUtils


  • public abstract class PropertiesLoaderUtils
    extends java.lang.Object
    Convenient utility methods for loading of java.util.Properties, performing standard handling of input streams.

    For more configurable properties loading, including the option of a customized encoding, consider using the PropertiesLoaderSupport class.

    Since:
    2.0
    Author:
    Juergen Hoeller, Rob Harrop
    See Also:
    PropertiesLoaderSupport
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void fillProperties(java.util.Properties props, EncodedResource resource)
      Fill the given properties from the given EncodedResource, potentially defining a specific encoding for the properties file.
      static void fillProperties(java.util.Properties props, Resource resource)
      Fill the given properties from the given resource (in ISO-8859-1 encoding).
      static java.util.Properties loadAllProperties(java.lang.String resourceName)
      Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the default class loader.
      static java.util.Properties loadAllProperties(java.lang.String resourceName, java.lang.ClassLoader classLoader)
      Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the given class loader.
      static java.util.Properties loadProperties(EncodedResource resource)
      Load properties from the given EncodedResource, potentially defining a specific encoding for the properties file.
      static java.util.Properties loadProperties(Resource resource)
      Load properties from the given resource (in ISO-8859-1 encoding).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PropertiesLoaderUtils

        public PropertiesLoaderUtils()
    • Method Detail

      • fillProperties

        public static void fillProperties(java.util.Properties props,
                                          EncodedResource resource)
                                   throws java.io.IOException
        Fill the given properties from the given EncodedResource, potentially defining a specific encoding for the properties file.
        Parameters:
        props - the Properties instance to load into
        resource - the resource to load from
        Throws:
        java.io.IOException - in case of I/O errors
      • loadProperties

        public static java.util.Properties loadProperties(Resource resource)
                                                   throws java.io.IOException
        Load properties from the given resource (in ISO-8859-1 encoding).
        Parameters:
        resource - the resource to load from
        Returns:
        the populated Properties instance
        Throws:
        java.io.IOException - if loading failed
        See Also:
        fillProperties(java.util.Properties, Resource)
      • fillProperties

        public static void fillProperties(java.util.Properties props,
                                          Resource resource)
                                   throws java.io.IOException
        Fill the given properties from the given resource (in ISO-8859-1 encoding).
        Parameters:
        props - the Properties instance to fill
        resource - the resource to load from
        Throws:
        java.io.IOException - if loading failed
      • loadAllProperties

        public static java.util.Properties loadAllProperties(java.lang.String resourceName)
                                                      throws java.io.IOException
        Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the default class loader.

        Merges properties if more than one resource of the same name found in the class path.

        Parameters:
        resourceName - the name of the class path resource
        Returns:
        the populated Properties instance
        Throws:
        java.io.IOException - if loading failed
      • loadAllProperties

        public static java.util.Properties loadAllProperties(java.lang.String resourceName,
                                                             @Nullable
                                                             java.lang.ClassLoader classLoader)
                                                      throws java.io.IOException
        Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the given class loader.

        Merges properties if more than one resource of the same name found in the class path.

        Parameters:
        resourceName - the name of the class path resource
        classLoader - the ClassLoader to use for loading (or null to use the default class loader)
        Returns:
        the populated Properties instance
        Throws:
        java.io.IOException - if loading failed