Java Utililty Methods Properties

List of utility methods to do Properties

Description

The list of methods to do Properties are organized into topic(s).

Method

voidmergePropertiesIntoMap(Properties props, Map map)
Merge the given Properties instance into the given Map, copying all properties (key-value pairs) over.
if (map == null) {
    throw new IllegalArgumentException("Map must not be null");
if (props != null) {
    for (Enumeration en = props.propertyNames(); en.hasMoreElements();) {
        String key = (String) en.nextElement();
        Object value = props.getProperty(key);
        if (value == null) {
...
voidmergePropertiesIntoMap(Properties props, Map map)
merge Properties Into Map
if (map == null) {
    throw new IllegalArgumentException("Map must not be null");
} else {
    if (props != null) {
        Enumeration en = props.propertyNames();
        while (en.hasMoreElements()) {
            String key = (String) en.nextElement();
            map.put(key, props.getProperty(key));
...
voidmergeSystemProperties(Properties properties)
Add properties to the system properties.
if (properties == null)
    return;
Enumeration enumeration = properties.propertyNames();
while (enumeration.hasMoreElements()) {
    String name = (String) enumeration.nextElement();
    if (System.getProperty(name) == null) {
        String value = properties.getProperty(name);
        System.setProperty(name, value);
...
ObjectpropertiesToJson(Properties properties)
properties To Json
Map<String, String> jsonObj = new HashMap<String, String>();
if (properties != null) {
    Set<String> keys = properties.stringPropertyNames();
    for (String key : keys) {
        jsonObj.put(key, properties.getProperty(key));
return jsonObj;
...
MappropertiesToMap(Properties props)
properties To Map
Map<String, String> map = new HashMap<>();
for (String key : props.stringPropertyNames()) {
    String value = props.getProperty(key);
    map.put(key, value);
return map;
voidputAll(final Map props, final Properties p)
put All
for (Enumeration<?> e = p.propertyNames(); e.hasMoreElements();) {
    String s = (String) e.nextElement();
    props.put(s, p.getProperty(s));
voidputAll(Properties properties, Map result)
Copies all elements from properties into the given result.
for (Enumeration<Object> keys = properties.keys(); keys.hasMoreElements();) {
    String key = (String) keys.nextElement();
    result.put(key, properties.getProperty(key));
PropertiesputPrefixToProperties(String prefix, Properties pro)
put Prefix To Properties
Enumeration en;
Properties res = new Properties();
en = pro.propertyNames();
for (; en.hasMoreElements();) {
    String nom = (String) en.nextElement();
    res.setProperty(prefix + nom, pro.getProperty(nom));
return res;
...
voidremoveDots(Properties props)
remove Dots
Enumeration keys = props.keys();
HashMap hash = new HashMap();
boolean done = false;
for (; keys.hasMoreElements();) {
    String key = (String) keys.nextElement();
    if (key.indexOf('.') != -1) {
        int len = key.length();
        int newLen = 0;
...
Mapsearch(List properties, String term)
search
Map<String, String> collect = properties.stream().filter(line -> line.split("=")[0].contains(term))
        .map(line -> {
            Map<String, String> stringStringHashMap = new HashMap<>();
            stringStringHashMap.put(line.split("=")[0], line.split("=")[1]);
            return stringStringHashMap;
        }).reduce((stringStringMap, stringStringMap2) -> {
            stringStringMap.putAll(stringStringMap2);
            return stringStringMap;
...