org.ops4j.util.collections
Class PropertiesWriter

java.lang.Object
  extended by org.ops4j.util.collections.PropertiesWriter

public class PropertiesWriter
extends Object

Helper for writing properties files.

Since:
0.5.0, Januray 16, 2008

Constructor Summary
PropertiesWriter(OutputStream outputStream)
          Creates a new property writer with default sperator (,).
PropertiesWriter(OutputStream outputStream, String separator)
          Creates a new property writer with a custom separator.
 
Method Summary
 PropertiesWriter append()
          Appends an empty line
 PropertiesWriter append(String comment)
          Appends a comment to be written.
 PropertiesWriter append(String key, String value)
          Appends a property to be written.
 PropertiesWriter appendRaw(String value)
          Appends a raw value = will be exactely as recived.
 void write()
          Write properties to output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesWriter

public PropertiesWriter(OutputStream outputStream)
Creates a new property writer with default sperator (,).

Parameters:
outputStream - the output stream to write properties to.

PropertiesWriter

public PropertiesWriter(OutputStream outputStream,
                        String separator)
Creates a new property writer with a custom separator.

Parameters:
outputStream - the output stream to write properties to.
separator - separator to be used to separate multiple properties
Throws:
NullArgumentException - if output stream or separator are null
Method Detail

append

public PropertiesWriter append(String key,
                               String value)
Appends a property to be written.

Parameters:
key - key of property
value - value of property
Returns:
self for a fluent api
Throws:
NullArgumentException - if key is null or empty

append

public PropertiesWriter append(String comment)
Appends a comment to be written.

Parameters:
comment - The comment to add to the Properties file.
Returns:
self for a fluent api

append

public PropertiesWriter append()
Appends an empty line

Returns:
self for a fluent api

appendRaw

public PropertiesWriter appendRaw(String value)
Appends a raw value = will be exactely as recived.

Parameters:
value - a raw value
Returns:
self for fluent api

write

public void write()
           throws IOException
Write properties to output stream.

Throws:
IOException - re-thrown from output stream


Copyright © 2006-2013 OPS4J - Open Participation Software for Java. All Rights Reserved.