Class PropertiesHelper

java.lang.Object
com.helger.base.rt.PropertiesHelper

@Immutable public final class PropertiesHelper extends Object
Helper class to ease the use of Properties class.
Author:
Philip Helger
  • Method Details

    • getAsStringMap

      @ReturnsMutableCopy public static @NonNull Map<String,String> getAsStringMap(@NonNull Properties aProps)
      Convert the passed Properties object to a simple Map with String keys and String values.
      Parameters:
      aProps - The properties to convert. May not be null.
      Returns:
      A new mutable map with all entries. Never null.
    • loadProperties

      public static @Nullable NonBlockingProperties loadProperties(@WillClose @NonNull InputStream aIS)
      Load properties from the given input stream.
      Parameters:
      aIS - The input stream to read from. May not be null. Will be closed.
      Returns:
      The loaded properties or null if loading failed.
    • loadProperties

      public static @Nullable NonBlockingProperties loadProperties(@WillClose @NonNull Reader aReader)
      Load properties from the given reader.
      Parameters:
      aReader - The reader to read from. May not be null. Will be closed.
      Returns:
      The loaded properties or null if loading failed.
    • expandSystemProperties

      public static @Nullable String expandSystemProperties(@Nullable String sValue)
      Copy of Oracle internal PropertyExpander.expand method
      Parameters:
      sValue - Source value. May be null.
      Returns:
      null if source is null.
      See Also:
    • expandProperties

      public static @Nullable String expandProperties(@Nullable String sValue, @NonNull UnaryOperator<String> aValueProvider)
      Special version of expandSystemProperties(String) that takes an arbitrary value provider and is not limited to system properties.
      Parameters:
      sValue - Source value. May be null.
      aValueProvider - The value provider to be used. May not be null.
      Returns:
      null if the source value is null.
      Since:
      9.1.2