Class PropertiesLoaderUtils

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

public abstract class PropertiesLoaderUtils extends 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, Sebastien Deleuze
See Also:
  • Constructor Details

    • PropertiesLoaderUtils

      public PropertiesLoaderUtils()
  • Method Details

    • loadProperties

      public static Properties loadProperties(EncodedResource resource) throws IOException
      Load properties from the given EncodedResource, potentially defining a specific encoding for the properties file.
      Throws:
      IOException
      See Also:
    • fillProperties

      public static void fillProperties(Properties props, EncodedResource resource) throws 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:
      IOException - in case of I/O errors
    • loadProperties

      public static Properties loadProperties(Resource resource) throws 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:
      IOException - if loading failed
      See Also:
    • fillProperties

      public static void fillProperties(Properties props, Resource resource) throws 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:
      IOException - if loading failed
    • loadAllProperties

      public static Properties loadAllProperties(String resourceName) throws 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:
      IOException - if loading failed
    • loadAllProperties

      public static Properties loadAllProperties(String resourceName, @Nullable ClassLoader classLoader) throws 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:
      IOException - if loading failed