Java Properties.store(Writer writer, String comments)

Syntax

Properties.store(Writer writer, String comments) has the following syntax.

public void store(Writer writer,  String comments)  throws IOException

Example

In the following code shows how to use Properties.store(Writer writer, String comments) method.


import java.io.StringWriter;
import java.util.Properties;
/*from   ww w  .j ava 2s  .  co m*/
public class Main {

  public static void main(String[] args) throws Exception {
    Properties prop = new Properties();
    StringWriter sw = new StringWriter();

    prop.setProperty("Chapter Count", "200");
    prop.put("Tutorial Count", "1500");
    prop.put("tutorial", "java2s.com");
    
    // print the list
    System.out.println(prop);

    // store the properties list in an output writer
    prop.store(sw, "Main");

    System.out.println(sw.toString());

  }
}

The code above generates the following result.