import java.io.*;
class TestProperty
{
public static void main(String[] args)
{
Properties psys=System.getProperties();
String path = psys.getProperty("user.dir");//程序所在的路径;
// psys.list(System.out);
//写文件
try
{
File f = new File(path+"\\config\\test.txt");
FileWriter fw = new FileWriter(f);
PrintWriter pw = new PrintWriter(fw);
Enumeration em= psys.propertyNames();
while(em.hasMoreElements())
{
String strKey=(String)em.nextElement();
String strValue = psys.getProperty(strKey);
pw.println(strKey+"="+strValue);
}
fw.close();
//读文件
File f1 = new File(path+"\\config\\test.txt");
FileReader fr = new FileReader(f1);
BufferedReader br= new BufferedReader(fr);
String content ="";
String str ="";
while((content=br.readLine())!=null)
{
str += content+"\r\n";
}
System.out.println(str);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
sun.boot.library.path=C:\Program Files\Java\jdk1.6.0_03\jre\bin
java.vm.version=1.6.0_03-b05
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=;
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
user.country=CN
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=Service Pack 2
java.vm.specification.name=Java Virtual Machine Specification
user.dir=D:\『Java』Java is not difficult By SunXin\javaLessons\lesson8
java.runtime.version=1.6.0_03-b05
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C:\Program Files\Java\jdk1.6.0_03\jre\lib\endorsed
os.arch=x86
java.io.tmpdir=C:\DOCUME~1\zhangran\LOCALS~1\Temp\
line.separator=
java.vm.specification.vendor=Sun Microsystems Inc.
user.variant=
os.name=Windows XP
sun.jnu.encoding=GBK
java.library.path=C:\Program Files\Java\jdk1.6.0_03\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;E:\apache-tomcat-6.0.10\bin;D:\oracle\product\10.1.0\Db_1\BIN;C:\Program Files\Java\jdk1.6.0_03\bin;d:\oracle\product\10.1.0\Db_1\jre\1.4.2\bin\client;d:\oracle\product\10.1.0\Db_1\jre\1.4.2\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\PROGRA~1\ATT\Graphviz\bin;;C:\PROGRA~1\ATT\Graphviz\bin;;C:\PROGRA~1\ATT\Graphviz\bin;D:\oracle\product\10.1.0\Db_1\BIN;d:\oracle\product\10.1.0\Db_1\jre\1.4.2\bin\client;d:\oracle\product\10.1.0\Db_1\jre\1.4.2\bin;;C:\Program Files\Java\jdk1.6.0_03\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;d:\Program Files\StormII\Codec;d:\Program Files\StormII;C:\Program Files\SSH Communications Security\SSH Secure Shell;d:\Program Files\StormII\Codec;d:\Program Files\StormII;d:\Program Files\StormII\Codec;d:\Program Files\StormII;d:\Program Files\StormII\Codec;d:\Program Files\StormII;d:\Program Files\StormII\Codec;d:\Program Files\StormII;d:\Program Files\StormII\Codec;d:\Program Files\StormII;d:\Program Files\StormII\Codec;d:\Program Files\StormII;d:\Program Files\StormII\Codec;d:\Program Files\StormII
java.specification.name=Java Platform API Specification
java.class.version=50.0
sun.management.compiler=HotSpot Client Compiler
os.version=5.1
user.home=C:\Documents and Settings\zhangran
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=GBK
java.specification.version=1.6
user.name=tiger
java.class.path=.;C:\Program Files\Java\jdk1.6.0_03\bin;C:\Program Files\Java\jdk1.6.0_03\lib\dt.jar;C:\Program Files\Java\jdk1.6.0_03\lib\tools.jar;C:\Program Files\Java\jre1.6.0_03\lib\ext\servlet-api.jar;E:\apache-tomcat-6.0.10\lib\servlet-api.jar
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=C:\Program Files\Java\jdk1.6.0_03\jre
java.specification.vendor=Sun Microsystems Inc.
user.language=zh
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode, sharing
java.version=1.6.0_03
java.ext.dirs=C:\Program Files\Java\jdk1.6.0_03\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
sun.boot.class.path=C:\Program Files\Java\jdk1.6.0_03\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_03\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_03\jre\classes
java.vendor=Sun Microsystems Inc.
file.separator=\
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=windows
sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86