Here you can find the source of propertiesToString(Properties p)
public static String propertiesToString(Properties p)
//package com.java2s; //License from project: LGPL import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.Properties; public class Main { public static String propertiesToString(Properties p) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(outStream); for (Object key : p.keySet()) { out.println(key + "=" + p.getProperty(key.toString())); }// ww w . j av a 2 s.co m out.close(); return new String(outStream.toByteArray()); } }