spring mvc学习(48):java判断系统是linux还是windows系统
生活随笔
收集整理的這篇文章主要介紹了
spring mvc学习(48):java判断系统是linux还是windows系统
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
java判斷系統(tǒng)是linux還是windows系統(tǒng)
?
判斷一個(gè)系統(tǒng)是windows還是linux?
import org.junit.jupiter.api.Test;/*** @program: utilsdemo* @description: 判斷運(yùn)行的系統(tǒng)是windows還是linux* @author: zhangyu* @create: 2019-08-12 10:07*/public class JudgeSystem {/*** @description: 判斷運(yùn)行的系統(tǒng)是不是linux* @author: zhangyu* @create: 2019-08-12*/public static boolean isLinux() {return System.getProperty("os.name").toLowerCase().contains("linux");}public static boolean isWindows() {return System.getProperty("os.name").toLowerCase().contains("windows");}public String JudgeSystem() {if (isLinux()) {return "linux";} else if (isWindows()) {return "windows";} else {return "other system";}}@Testpublic void fun() {boolean flag1 = isLinux();// System.out.println(flag1);boolean flag2 = isWindows();// System.out.println(flag2);// System.out.println(System.getProperty("os.name"));String sys = JudgeSystem();System.out.println(sys);}}?
總結(jié)
以上是生活随笔為你收集整理的spring mvc学习(48):java判断系统是linux还是windows系统的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: NERO-光盘刻录程序教程集
- 下一篇: 第四十二期:Linux转正日常办公电脑到