System. setProperty and System. getProperty

Source: Internet
Author: User
Tags file separator

System supports standard input, standard output, and error output streams, access to externally defined attributes and environment variables, and methods for loading files and libraries; there is also a practical method to quickly copy part of the array.
System. getProperties () can be used to determine the current System attribute. The returned value is a Properties;
System. load (String filename) is equivalent to: System. getProperties (). load (String filename) is used to load code files from the file names specified in the local file system of dynamic mode.

System. setProperties (Properties propes): sets the System property to the Properties parameter;
System. setProperties (String key, String value) is equivalent to System. getProperties (). setProperties (String key, String value): set the System attribute indicated by the specified key

If you want to obtain the corresponding key-Value Pair in a resource file in a program, you can use either of the following methods:
1) Use the load method of Properties to load the file first, and then use the getProperty method to make the corresponding key worthwhile. For example:
System. getProperties (). load ("System.Properties.txt" contains the file System.Properties.txt first.
System. getProperties (). getProperty ("DBType.
2) It is worth a lot of flexibility to use the first method key. Another way is to not get the key value from the file. Set an attribute in the program, for example:
System. getProperties (). setProperty ("DBType", "SQLServer"); first set the attribute of DBType
System. getProperties (). getProperty ("DBType"); then, the value of DBType is obtained through the getProperty method.

In addition, some system environment variables can be used for parameters using the Properties. getProperty method. The list is as follows:
Key Meaning
-------------------------------------------------
"File. separator" File separator (e.g .,"/")
"Java. class. path" Java classpath
"Java. class. version" Java class version number
"Java. home" Java installation directory
"Java. vendor" Java vendor-specific string

"Java. vendor. url" Java vendor URL
"Java. version" Java version number
"Line. separator" Line separator
"OS. arch" Operating system architecture
"OS. name" Operating system name

"Path. separator" Path separator (e.g .,":")
"User. dir" User's current working directory
"User. home" User home directory
"User. name" User account name

Use the key to obtain some attributes for use in the program.

Note:
Microsoft VM is a virtual machine in the WIN32 operating environment. It is generally installed in most operating systems and is also included in most IE.
Microsoft VM vulnerabilities allow attackers to access the user. dir attribute. The user. dir attribute contains the working directory information of the current application and the user name. This vulnerability can be exploited to obtain the current user name.
Web pages and HTML emails can be used for triggering.

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.