Java Properties to Map propertiesToMap(File propsFile)

Here you can find the source of propertiesToMap(File propsFile)

Description

properties To Map

License

Apache License

Declaration

public static Map<?, ?> propertiesToMap(File propsFile)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class Main {
    public static Map<?, ?> propertiesToMap(File propsFile)
            throws IOException {
        Map<String, String> map = new HashMap<String, String>();

        InputStream inStream = new FileInputStream(propsFile);
        Properties props = new Properties();
        props.load(inStream);/*from  ww w  .  ja va 2  s . c  o m*/

        for (String key : props.stringPropertyNames()) {
            map.put(key, props.getProperty(key));
        }

        return props;
    }
}

Related

  1. propertiesToMap(String propertiesAsString)
  2. toMap(final Properties properties)
  3. toMap(final Properties properties)
  4. toMap(Properties properties)