Java Properties to Map toMap(final Properties properties)

Here you can find the source of toMap(final Properties properties)

Description

Converts a Properties object to a string-to-string Map .

License

Open Source License

Parameter

Parameter Description
properties Properties

Return

String-to-string map

Declaration

public static Map<String, String> toMap(final Properties properties) 

Method Source Code

//package com.java2s;
/*/*from w ww . j  a  v  a2 s  . c om*/
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2001-2005 Julian Hyde
// Copyright (C) 2005-2012 Pentaho and others
// All Rights Reserved.
*/

import java.util.*;

public class Main {
    /**
     * Converts a {@link Properties} object to a string-to-string {@link Map}.
     *
     * @param properties Properties
     * @return String-to-string map
     */
    public static Map<String, String> toMap(final Properties properties) {
        return new AbstractMap<String, String>() {
            @SuppressWarnings({ "unchecked" })
            public Set<Entry<String, String>> entrySet() {
                return (Set) properties.entrySet();
            }
        };
    }
}

Related

  1. propertiesToMap(File propsFile)
  2. propertiesToMap(String propertiesAsString)
  3. toMap(final Properties properties)
  4. toMap(Properties properties)
  5. toMap(Properties properties)
  6. toMap(Properties properties)