Properties.store(Writer writer, String comments) has the following syntax.
public void store(Writer writer, String comments) throws IOException
In the following code shows how to use Properties.store(Writer writer, String comments) method.
import java.io.StringWriter; import java.util.Properties; //from w w w.ja v a 2s . c om 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.