Java Properties to toString(Properties props)

Here you can find the source of toString(Properties props)

Description

to String

License

Open Source License

Declaration

public static String toString(Properties props) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
 * Distributed under license by Red Hat, Inc. All rights reserved.
 * This program is 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://from  w w w. j a v  a 2  s.c  o  m
 *     Exadel, Inc. and Red Hat, Inc. - initial API and implementation
 ******************************************************************************/

import java.util.*;

public class Main {
    public static String toString(Properties props) {
        Iterator it = props.entrySet().iterator();
        String s = ""; //$NON-NLS-1$
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            s += (s.length() > 0 ? "," : "") + entry.getKey() + "=" + entry.getValue(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }
        return s;
    }
}

Related

  1. PropertiesToInputStream(Properties p)
  2. propertiesToXmlByteArray(Properties p)
  3. toStringProperties(String name, Properties props)