使用Java判斷作業系統

2021-06-21 13:55:13 字數 516 閱讀 1099

最近工作中需要判斷使用系統命令(mv/move)移動檔案。首先要判斷作業系統,使用apache commons lang包的systemutils可以解決這個問題。截圖如下:

**如下:

import org.apache.commons.lang3.systemutils;

public class ostype

// 獲取ostype

public static ostypeenum getostype()

if (systemutils.is_os_unix)

return ostypeenum.other;

}}

ostypeenum:

public enum ostypeenum
結果:(測試結果)

windows

判斷作業系統

判斷作業系統.cpp 定義控制台應用程式的入口點。include stdafx.h include void getsystem if i 5 j 0 else if i 5 j 1 else if i 5 j 2 else if i 6 j 0 else if i 6 j 1 int tmain ...

InstallScript之判斷作業系統

判斷當前的作業系統是否為win2003或者winxp if sysinfo.winnt.bwinserver2003 sysinfo.winnt.bwinxp then 提示資訊中英文現實 if selected language islang english then szmsg your cur...

python判斷作業系統型別

經常地我們需要編寫跨平台的指令碼,但是由於不同的平台的差異性,我們不得不獲得當前所工作的平台 作業系統型別 如下 import platform deftestplatform print operation system windows will be 32bit,windowspe linux ...