What key is there in Java GetProperty?

Source: Internet
Author: User
Tags file separator

Recently in the making of a gadget, although the previous tool can detect whether the URL is legitimate, can determine whether the connection. But not enough, there will be another article on the tool improvement, can output the name of the download resources, because the URL itself will jump to the corresponding download resources, I need to check whether these things downloaded correctly.


The tool itself is cleverly written to copy the address into the TXT file. I was thinking about realizing the idea before I read the source code myself.


BAT control compilation, data from the TXT read, the only thing I don't understand is why no matter where I put, he can read the TXT file location, which I do not think of the place, but after reading the source, it dawned. In fact, the use of System.getproperty ("User.dir") to obtain a relative path, out of interest, I found the JDK inside the instructions, and recently re-read the properties of the operation, for the Traverse Basic is handy.


public class Testproperties {public static void main (string[] args) {Properties p = system.getproperties (); Enumeration keys = P.keys (); while (Keys.hasmoreelements ()) {String s = (String) keys.nextelement (); System.out.println ("key:" +s); System.out.println ("Value:" +p.getproperty (s));}}}

look at the output:

Key:java.runtime.namevalue:Java (TM) SE runtime Environmentkey:sun.boot.library.pathvalue:c:\program files\java\ Jdk1.7.0_67\jre\binkey:java.vm.versionvalue:24.65-b04key:java.vm.vendorvalue:oracle Corporationkey: Java.vendor.urlvalue:http://java.oracle.com/key:path.separatorvalue:; Key:java.vm.namevalue:Java HotSpot (TM) 64- Bit Server VMkey:file.encoding.pkgvalue:sun.iokey:user.countryvalue:CNkey:user.scriptvalue:key: Sun.java.launchervalue:SUN_STANDARDkey:sun.os.patch.levelvalue:Service Pack 1key:java.vm.specification.namevalue : Java Virtual Machine specificationkey:user.dirvalue:e:\workspace\testnetkey:java.runtime.versionvalue:1.7.0_67- B01key:java.awt.graphicsenvvalue:sun.awt.win32graphicsenvironmentkey:java.endorsed.dirsvalue:c:\program Files\ Java\jdk1.7.0_67\jre\lib\endorsedkey:os.archvalue:amd64key:java.io.tmpdirvalue:c:\users\admini~1\appdata\local \tempkey:line.separatorvalue:key:java.vm.specification.vendorvalue:oracle Corporationkey:user.varIantvalue:key:os.namevalue:Windows 7key:sun.jnu.encodingvalue:gbkkey:java.library.pathvalue:c:\program files\ Java\jdk1.7.0_67\bin; C:\Windows\Sun\Java\bin; C:\Windows\system32; C:\Windows; C:\Windows\system32; C:\Windows; C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\;D: \tomcat7\lib;d:\tomcat7\bin;d:\ant1.8.2\bin; C:\Program Files\java\jdk1.7.0_67\bin; C:\Program Files\tortoisesvn\bin;d:\jar\apache-maven-3.2.3-bin\bin;d:\program files\appserv\apache2.2\bin;d:\ Program Files\appserv\php6;d:\program Files\appserv\mysql\bin;. Key:java.specification.namevalue:Java Platform API Specificationkey:java.class.versionvalue:51.0key: Sun.management.compilervalue:HotSpot 64-bit Tiered Compilerskey:os.versionvalue:6.1key:user.homevalue:c:\users\ Administratorkey:user.timezonevalue:key:java.awt.printerjobvalue:sun.awt.windows.WPrinterJobkey: File.encodingvalue:utf-8key:java.specification.versionvalue:1.7key:java.class.pathvalue:e:\workspace\testnet\ Binkey:user.namEvalue:administratorkey:java.vm.specification.versionvalue:1.7key:sun.java.commandvalue:testpropertieskey: Java.homevalue:c:\program Files\java\jdk1.7.0_67\jrekey:sun.arch.data.modelvalue:64key:user.languagevalue:zhkey : Java.specification.vendorvalue:Oracle Corporationkey:awt.toolkitvalue:sun.awt.windows.WToolkitkey: Java.vm.infovalue:mixed Modekey:java.versionvalue:1.7.0_67key:java.ext.dirsvalue:c:\program files\java\jdk1.7.0_ 67\jre\lib\ext; C:\windows\sun\java\lib\extkey:sun.boot.class.pathvalue:c:\program Files\java\jdk1.7.0_67\jre\lib\resources.jar ; C:\Program Files\java\jdk1.7.0_67\jre\lib\rt.jar; C:\Program Files\java\jdk1.7.0_67\jre\lib\sunrsasign.jar; C:\Program Files\java\jdk1.7.0_67\jre\lib\jsse.jar; C:\Program Files\java\jdk1.7.0_67\jre\lib\jce.jar; C:\Program Files\java\jdk1.7.0_67\jre\lib\charsets.jar; C:\Program Files\java\jdk1.7.0_67\jre\lib\jfr.jar; C:\Program files\java\jdk1.7.0_67\jre\classeskey:java.vendorvalue:oracle Corporationkey:file.separatorvalue: Key:java.vendor.url.bugvalue:http://bugreport.sun.com/bugreport/key:sun.io.unicode.encodingvalue: UnicodeLittlekey:sun.cpu.endianvalue:littlekey:sun.desktopvalue:windowskey:sun.cpu.isalistvalue:amd64

Description of each key

Key Description of associated Value java.version Java Runtime Environment version Java.vendor Java Runtime Environment ven Dor java.vendor.url Java Vendor URL java.home java installation directory java.vm.specification.version java Virtual Machi NE specification version java.vm.specification.vendor Java Virtual Machine specification vendor Java.vm.specification.name Java Virtual Machine specification name java.vm.version Java Virtual machine implementation ve Rsion Java.vm.vendor Java Virtual machine Implementation Vendor Java.vm.name Java Virtual Machine implementation name Java . specification.version Java Runtime Environment specification version Java.specification.vendor Java runtime Environment specification Vendor Java.specification.name Java Runtime Environment Specification name Java.class.version Java class format version number Java.class.path Java class path Java.library.path List of paths to search when loading Li Braries Java.io.tmpdir Default Temp file path Java.compiler Name oF JIT compiler to use java.ext.dirs Path of extension directory or directories os.name Operating system name Os.arch Opera Ting system Architecture os.version Operating System version file.separator file separator ("/" on UNIX) Path.separator Pa Th separator (":" on Unix) Line.separator line separator ("\ n" on Unix) User.Name user's account name user.home user ' s hom  E directory user.dir user ' s current working directory


And then reminds me of a long time ago a package to the method, Sun.arch.data.model actually look at the operating system architecture, is your Windows or other OS is several.


The system.getproperty ("User.dir") method of obtaining the current working path is also useful.

What key is there in Java GetProperty?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.