Java Properties Create toProperties(final Map map)

Here you can find the source of toProperties(final Map map)

Description

Gets a new Properties object initialised with the values from a Map.

License

Open Source License

Parameter

Parameter Description
map the map to convert to a Properties object, may not be null

Return

the properties object

Declaration

public static Properties toProperties(final Map map) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    /**/*from w w w. java  2 s . co m*/
     * Gets a new Properties object initialised with the values from a Map.
     * A null input will return an empty properties object.
     *
     * @param map  the map to convert to a Properties object, may not be null
     * @return the properties object
     */
    public static Properties toProperties(final Map map) {
        Properties answer = new Properties();
        if (map != null) {
            for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
                Map.Entry entry = (Map.Entry) iter.next();
                Object key = entry.getKey();
                Object value = entry.getValue();
                answer.put(key, value);
            }
        }
        return answer;
    }
}

Related

  1. toPrettyPrintJSON(Object object)
  2. toProperties(byte[] source)
  3. toProperties(byte[] source)
  4. toProperties(File properties, File xml, String comment)
  5. toProperties(FileInputStream fis)
  6. toProperties(final String value)
  7. toProperties(String jsonStr)
  8. toProperties(String props)
  9. toRawString(Properties props)