Here you can find the source of toMap(Properties properties)
Map<String, String>
out of a Java Properties object.
Parameter | Description |
---|---|
properties | the properties object to convert |
public static Map<String, String> toMap(Properties properties)
//package com.java2s; /*//ww w .ja v a 2 s . c o m * ======================================================================== * * Codehaus CARGO, copyright 2004-2011 Vincent Massol, 2012-2018 Ali Tokmen. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ======================================================================== */ import java.util.HashMap; import java.util.Map; import java.util.Properties; public class Main { /** * Returns a <code>Map<String, String></code> out of a Java Properties object. * * @param properties the properties object to convert * @return Java Map corresponding to the Java Properties object. */ public static Map<String, String> toMap(Properties properties) { Map<String, String> result = new HashMap<String, String>(properties.size()); for (Map.Entry<Object, Object> parameter : properties.entrySet()) { String value = null; if (parameter.getValue() != null) { value = parameter.getValue().toString(); } result.put(parameter.getKey().toString(), value); } return result; } }