java 系统自动检测_如何在Java中检测OS(操作系统)名称?
java 系統(tǒng)自動檢測
To detect the OS (operating system) name in Java, we use the getProperties() method, which is defined in System class, while calling the method, we need to pass the property name to get the OS (operating system name).
要檢測Java中的OS(操作系統(tǒng))名稱 ,我們使用System類中定義的getProperties()方法 ,在調(diào)用該方法時(shí),我們需要傳遞屬性名稱以獲取OS(操作系統(tǒng)名稱)。
The property to get the OS name is: "os.name"
獲取操作系統(tǒng)名稱的屬性是: “ os.name”
The method call is: System.getProperties("os.name");
方法調(diào)用為: System.getProperties(“ os.name”);
Java code to detect and print the OS (operating system) name
用于檢測和打印OS(操作系統(tǒng))名稱的Java代碼
// Java program to demonstrate the example of // getProperties() method of System Classimport java.lang.*; import java.util.Properties;public class Main {public static void main(String[] args) {String os_name = null;os_name = System.getProperty("os.name");System.out.println("OS name is: " + os_name);} }Output
輸出量
OS name is: Linux翻譯自: https://www.includehelp.com/java/how-to-detect-the-os-operating-system-name-in-java.aspx
java 系統(tǒng)自動檢測
總結(jié)
以上是生活随笔為你收集整理的java 系统自动检测_如何在Java中检测OS(操作系统)名称?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python字符串转浮点数_Python
- 下一篇: c语言 关键字const_C ++ co