Java Properties Save savePropertiesToString(Properties props, String comment)

Here you can find the source of savePropertiesToString(Properties props, String comment)

Description

save Properties To String

License

Open Source License

Parameter

Parameter Description
props a parameter
comment a parameter

Exception

Parameter Description
IOException an exception

Return

the string

Declaration

public static String savePropertiesToString(Properties props, String comment) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006 Sybase, Inc. 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://from w  w w . j  a  v  a  2s . c  o m
 *     Sybase, Inc. - initial API and implementation
 *******************************************************************************/

import java.io.ByteArrayOutputStream;

import java.io.IOException;

import java.util.Properties;

public class Main {
    /**
     * @param props
     * @param comment
     * @return the string
     * @throws IOException
     */
    public static String savePropertiesToString(Properties props, String comment) throws IOException {
        if (props == null)
            return null;
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        props.store(out, comment);
        String tmpString = out.toString();
        out = null;
        return tmpString;
    }
}

Related

  1. saveProperties(Properties props, File location)
  2. saveProperties(String fileName, Properties properties)
  3. saveProperties(String fileName, Properties properties, String title)
  4. saveProperties(String propName, Properties props)
  5. savePropertiesToEncodedString(Properties props, String comment)
  6. saveProperty(String key, String value)
  7. saveProperty(String key, String value)
  8. saveProperty(String key, String value)
  9. saveProps(Properties p, String fname, String comment)