Java.util.Properties.store(Writer writer,String comments) 方法


Java.util.Properties.store(Writer writer,String comments) 方法

package com.codingdict;

import java.io.IOException;
import java.io.StringWriter;
import java.util.*;

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

      // add some properties
      prop.setProperty("Height", "200");
      prop.put("Width", "1500");

      // print the list
      System.out.println("" + prop);

      try {

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

         // print the writer
         System.out.println("" + sw.toString());
      } catch (IOException ex) {
         ex.printStackTrace();
      }
   }
}