Java Utililty Methods Properties to String

List of utility methods to do Properties to String

Description

The list of methods to do Properties to String are organized into topic(s).

Method

StringpropertiesToString(final Properties p)
properties To String
if (p == null) {
    return "";
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
    p.store(baos, "");
} catch (final Exception ignored) {
return new String(baos.toByteArray());
StringpropertiesToString(final Properties properties)
properties To String
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
properties.list(pw);
return sw.toString();
StringpropertiesToString(Properties p)
properties To String
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
PrintStream out = new PrintStream(outStream);
for (Object key : p.keySet()) {
    out.println(key + "=" + p.getProperty(key.toString()));
out.close();
return new String(outStream.toByteArray());
StringpropertiesToString(Properties properties)
properties To String
StringWriter writer = new StringWriter();
PrintWriter out = new PrintWriter(writer);
Set<Object> keys = properties.keySet();
for (Object key : keys) {
    out.println(key + "=" + properties.get(key));
return writer.getBuffer().toString();
StringpropertiesToString(Properties properties)
Serializes properties to String
StringWriter stringWriter = new StringWriter();
String comments = Properties.class.getName();
try {
    properties.store(stringWriter, comments);
} catch (IOException e) {
    throw new RuntimeException(e);
stringWriter.flush();
...
StringpropertiesToString(Properties props)
Receives a Properties and converts it to a String.
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;
StringpropertiesToString(Properties props, String comment)
Converts properties to string representation
StringWriter writer = new StringWriter();
try {
    props.store(writer, comment);
} catch (IOException e) {
return writer.toString();