Java Properties Load from InputStream loadPropertiesInputStreamToMap(InputStream propertiesInputStream)

Here you can find the source of loadPropertiesInputStreamToMap(InputStream propertiesInputStream)

Description

load Properties Input Stream To Map

License

Open Source License

Declaration

public static Map<String, String> loadPropertiesInputStreamToMap(InputStream propertiesInputStream)
            throws IOException 

Method Source Code

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

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<String, String> loadPropertiesInputStreamToMap(InputStream propertiesInputStream)
            throws IOException {
        Properties properties = new Properties();
        properties.load(propertiesInputStream);
        return propertiesToMap(properties);
    }/*from  w w w .  ja va  2 s  .  c  o m*/

    public static <K, V> Map<K, V> propertiesToMap(Properties properties) {
        Map<K, V> resultMap = new HashMap<>();
        for (Object propertyKey : properties.keySet()) {
            resultMap.put((K) propertyKey, (V) properties.get((K) propertyKey));
        }
        return resultMap;
    }
}

Related

  1. loadProperties(InputStream inputStream, Properties result)
  2. loadProperties(InputStream stream)
  3. loadProperties(Properties props, InputStream inputStream)
  4. loadPropertiesFileFromStream(InputStream stream)
  5. loadPropertiesFromStream(InputStream inputStream)
  6. loadPropertiesStream(InputStream input)