Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;

import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Properties;

public class Main {
    /**
     * Convert a {@link Properties} into a {@link HashMap}.<br />
     * @param properties
     *        the properties to convert.
     * @return the map with the same objects.
     */
    public static Map<String, String> convertPropertiesToMap(final Properties properties) {
        Objects.requireNonNull(properties);
        final Map<String, String> map = new HashMap<>(properties.size());
        for (final Entry<Object, Object> property : properties.entrySet()) {
            // Properties are always Strings (left as Object in JDK for backward compatibility purposes)
            map.put((String) property.getKey(), (String) property.getValue());
        }
        return map;
    }
}