Java Properties to String propertiesToString(Properties props)

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

Description

Receives a Properties and converts it to a String.

License

Open Source License

Declaration

public static String propertiesToString(Properties props) throws Exception 

Method Source Code


//package com.java2s;
import java.io.PrintWriter;

import java.io.StringWriter;

import java.util.Properties;

public class Main {
    /**//from   ww  w. ja va2 s  .  co  m
     * Receives a <code>Properties</code> and converts it
     * to a String.
     */
    public static String propertiesToString(Properties props) throws Exception {
        StringWriter stringWriter = new StringWriter();
        PrintWriter printWriter = new PrintWriter(stringWriter);
        props.store(printWriter, null);
        String s = stringWriter.toString();
        s = s.substring(s.indexOf("\n") + 1);
        return s;
    }
}

Related

  1. propertiesToString(final Properties p)
  2. propertiesToString(final Properties properties)
  3. propertiesToString(Properties p)
  4. propertiesToString(Properties properties)
  5. propertiesToString(Properties properties)
  6. propertiesToString(Properties props, String comment)