Saving a property list to disk

Use the store method. Check out the following example that stores the system properties to a specified file.

Main.java:

import java.util.*;
import java.io.*;
 
public class Main {   
   public static void main(String[] args) throws Exception {
      if (args.length != 1) {
         System.out.println("Usage: java Main <filename>");
         System.exit(1);
      }
 
      BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(args[0]));
      Properties p = System.getProperties();
      p.store(bos, "Our stored System properties");     
   }
}

stores in a specified file:

#Our stored System properties
#Wed Jun 27 17:21:15 CEST 2001
java.specification.name=Java Platform API Specification
awt.toolkit=sun.awt.windows.WToolkit
java.version=1.2.2
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
user.timezone=Europe/Paris
java.specification.version=1.2
java.vm.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
user.home=C:\WINDOWS
os.arch=x86
java.awt.fonts=
java.vendor.url=http://java.sun.com/
file.encoding.pkg=sun.io
user.region=US
java.home=C:\JDK1.2.2\JRE
java.class.path=c:\jdk1.2.2\jre\lib\rt.jar;C:\PRO
GRA~1\JMF2.1\LIB\SOUND.JAR;C:\PROGRA~1\JMF2.1\LIB\
JMF.JAR;c:\jakarta-log4j-1.0.4\log4j-core.jar;
line.separator=rn
java.ext.dirs=C:\JDK1.2.2\JRE\lib\ext
java.io.tmpdir=c:\windows\TEMP\
os.name=Windows 95
java.vendor=Sun Microsystems Inc.
java.awt.printerjob=sun.awt.windows.WPrinterJob
java.library.path=C:\JDK1.2.2\BIN;.;C:\WINDOWS\SYSTEM;C:\WINDOWS;C:\JIKES\BIN
;C:\ANT\BIN\;C:\JDK1.2.2\BIN;C:\WINDOWS;C:\WIN
DOWS;C:\WINDOWS\COMMAND;;C:\WN16\BIN;C:\PROGRA~1
NETWOR~1\PGP;C:\VIM\VIM55
java.vm.specification.vendor=Sun Microsystems Inc.
sun.io.unicode.encoding=UnicodeLittle
file.encoding=Cp1252
java.specification.vendor=Sun Microsystems Inc.
user.name=esus
user.language=en
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
java.vm.name=Classic VM
java.vm.specification.name=Java Virtual Machine Specification
java.class.version=46.0
sun.boot.library.path=C:\JDK1.2.2\JRE\bin
os.version=4.10
java.vm.info=build JDK-1.2.2_005, native threads, symcjit
java.vm.version=1.2.2
java.compiler=symcjit
path.separator=;
user.dir=C:\
file.separator=\
sun.boot.class.path=C:\JDK1.2.2\JRE\lib\rt.jar;C:\
JDK1.2.2\JRE\lib\i18n.jar;C:\JDK1.2.2\JRE\classes