eg.
System.out.println("os.name "+System.getProperty("os.name"));
System.out.println("os.version "+System.getProperty("os.version"));
SDK帮助文档
java.lang.System
public static String getProperty (String prop)
Since: API Level 1
Returns the value of a particular system property or null if no such property exists.
The properties currently provided by the virtual machine are:
java.vendor.url java.class.path user.home java.class.version os.version java.vendor user.dir user.timezone path.separator os.name os.arch line.separator file.separator user.name java.version java.home
Parameters
| prop | the name of the system property to look up. |
|---|
Returns
- the value of the specified system property or
nullif the property doesn't exist.
Throws
| SecurityException | if a SecurityManager is installed and its checkPropertyAccess() method does not allow the operation. |
|---|
本文介绍如何使用Java的System类来获取操作系统的名称和版本等系统属性,并提供了详细的代码示例及解释。

被折叠的 条评论
为什么被折叠?



