关闭

9.34.2.使用系统属性 using properties

403人阅读 评论(0) 收藏 举报
import java.io.FileInputStream;
import java.util.Properties;
public class PropertiesTest2{
	public static void main(String[] args) throws Exception{
		Properties properties = System.getProperties();//确定当前系统属性
		properties.list(System.out);//属性的清单、列表
		
		FileInputStream in = null;
		in = new FileInputStream(args[0]);
		properties.load(in);
		
		System.getProperties().list(System.out);
		System.out.println("\nValue of local.animal.defined is" + Boolean.getBoolean("local.animal.defined"));
		System.out.println("\nValue of local.animal.legcount is" + Integer.getInteger("local.animal.legcount"));
	}
}

-- listing properties --
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=C:\Program Files\Java\jre6\bin
java.vm.version=20.1-b02
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 3
java.vm.specification.name=Java Virtual Machine Specification
user.dir=E:\java\Test
java.runtime.version=1.6.0_26-b03
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C:\Program Files\Java\jre6\lib\endorsed
os.arch=x86
java.io.tmpdir=C:\DOCUME~1\ADMINI~1\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:\WINDOWS\system32;C:\WINDOWS\Sun\Ja...
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\Administrator
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=GBK
java.specification.version=1.6
user.name=Administrator
java.class.path=.;C:\Program Files\Java\jre6\lib\ext\...
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=C:\Program Files\Java\jre6
sun.java.command=PropertiesTest2
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_26
java.ext.dirs=C:\Program Files\Java\jre6\lib\ext;C:...
sun.boot.class.path=C:\Program Files\Java\jre6\lib\resour...
java.vendor=Sun Microsystems Inc.
file.separator=\
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=windows
sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+m...
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at PropertiesTest2.main(PropertiesTest2.java:9)

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:280975次
    • 积分:4124
    • 等级:
    • 排名:第7457名
    • 原创:5篇
    • 转载:0篇
    • 译文:136篇
    • 评论:131条
    最新评论