Package jodd.util

Class PropertiesUtil

java.lang.Object
jodd.util.PropertiesUtil

public class PropertiesUtil extends Object
Misc java.util.Properties utils.
  • Constructor Details

    • PropertiesUtil

      public PropertiesUtil()
  • Method Details

    • createFromFile

      public static Properties createFromFile(String fileName) throws IOException
      Create properties from the file.
      Parameters:
      fileName - properties file name to load
      Throws:
      IOException
    • createFromFile

      public static Properties createFromFile(File file) throws IOException
      Create properties from the file.
      Parameters:
      file - properties file to load
      Throws:
      IOException
    • loadFromFile

      public static void loadFromFile(Properties p, String fileName) throws IOException
      Loads properties from the file. Properties are appended to the existing properties object.
      Parameters:
      p - properties to fill in
      fileName - properties file name to load
      Throws:
      IOException
    • loadFromFile

      public static void loadFromFile(Properties p, File file) throws IOException
      Loads properties from the file. Properties are appended to the existing properties object.
      Parameters:
      p - properties to fill in
      file - file to read properties from
      Throws:
      IOException
    • writeToFile

      public static void writeToFile(Properties p, String fileName) throws IOException
      Writes properties to a file.
      Parameters:
      p - properties to write to file
      fileName - destination file name
      Throws:
      IOException
    • writeToFile

      public static void writeToFile(Properties p, String fileName, String header) throws IOException
      Writes properties to a file.
      Parameters:
      p - properties to write to file
      fileName - destination file name
      header - optional header
      Throws:
      IOException
    • writeToFile

      public static void writeToFile(Properties p, File file) throws IOException
      Writes properties to a file.
      Parameters:
      p - properties to write to file
      file - destination file
      Throws:
      IOException
    • writeToFile

      public static void writeToFile(Properties p, File file, String header) throws IOException
      Writes properties to a file.
      Parameters:
      p - properties to write to file
      file - destination file
      header - optional header
      Throws:
      IOException
    • createFromString

      public static Properties createFromString(String data) throws IOException
      Creates properties from string.
      Throws:
      IOException
    • loadFromString

      public static void loadFromString(Properties p, String data) throws IOException
      Loads properties from string.
      Throws:
      IOException
    • subset

      public static Properties subset(Properties p, String prefix, boolean stripPrefix)
      Creates new Properties object from the original one, by copying those properties that have specified first part of the key name. Prefix may be optionally stripped during this process.
      Parameters:
      p - source properties, from which new object will be created
      prefix - key names prefix
      Returns:
      subset properties
    • getProperty

      public static String getProperty(Map map, String key)
      Returns String property from a map. If key is not found, or if value is not a String, returns null. Mimics Property.getProperty but on map.
    • getProperty

      public static String getProperty(Map map, String key, String defaultValue)
      Returns String property from a map.
      See Also:
    • resolveAllVariables

      public static void resolveAllVariables(Properties prop)
      Resolves all variables.
    • resolveProperty

      public static String resolveProperty(Map map, String key)
      Returns property with resolved variables.