Here you can find the source of toStringProperties(String name, Properties props)
Parameter | Description |
---|---|
name | name of properties |
props | properties whose keys and values will be printed out. |
public static String toStringProperties(String name, Properties props)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w w w. jav a 2s .c om*/ * IBM Corporation - initial API and implementation *******************************************************************************/ import java.util.*; public class Main { /** * get String representing the given properties. * * @param name name of properties * @param props properties whose keys and values will be printed out. */ public static String toStringProperties(String name, Properties props) { if (props == null || props.size() == 0) { return "Props(" + name + ") is empty\n"; } StringBuffer sb = new StringBuffer(); sb.append("Props(" + name + ") is \n"); for (Enumeration enumeration = props.keys(); enumeration.hasMoreElements();) { String key = (String) enumeration.nextElement(); sb.append("\tkey=" + key + "\tvalue=" + props.getProperty(key) + "\n"); } return sb.toString(); } }