-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
262d5f3
commit 834f1f6
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
yc-common/yc-common-core/src/main/java/com/yc/common/core/base/utils/JudgeSysUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.yc.common.core.base.utils; | ||
|
||
/** | ||
* @description: | ||
* @author: youcong | ||
*/ | ||
public class JudgeSysUtil { | ||
|
||
private static final String OS_NAME = "os.name"; | ||
|
||
private static final String LINUX_SYS = "linux"; | ||
|
||
private static final String WINDOWS_SYS = "windows"; | ||
|
||
private static final String OTHER_SYS = "other system"; | ||
|
||
/** | ||
* Linux | ||
* | ||
* @return | ||
*/ | ||
public static boolean isLinux() { | ||
return System.getProperty(OS_NAME).toLowerCase().contains("linux"); | ||
} | ||
|
||
/** | ||
* Windows | ||
* | ||
* @return | ||
*/ | ||
public static boolean isWindows() { | ||
return System.getProperty(OS_NAME).toLowerCase().contains("windows"); | ||
} | ||
|
||
/** | ||
* 判断当前操作系统 | ||
* | ||
* @return | ||
*/ | ||
public static String JudgeSystem() { | ||
if (isLinux()) { | ||
return LINUX_SYS; | ||
} else if (isWindows()) { | ||
return WINDOWS_SYS; | ||
} else { | ||
return OTHER_SYS; | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println("current system is:" + JudgeSysUtil.JudgeSystem()); | ||
} | ||
} |