Convert properties As Map - Java java.util

Java examples for java.util:Properties File

Description

Convert properties As Map

Demo Code


//package com.java2s;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Map.Entry;

public class Main {
    public static Map<String, String> propertiesAsMap(Properties properties) {

        Set<Entry<Object, Object>> entries = properties.entrySet();

        Map<String, String> responseMap = new HashMap<String, String>();

        for (Entry<Object, Object> entry : entries) {
            responseMap.put((String) entry.getKey(),
                    (String) entry.getValue());
        }/* w  w  w  . ja v a2s.  c om*/

        return responseMap;

    }
}

Related Tutorials