当前位置: 首页 > 后端技术 > Java

Java判断操作系统

时间:2023-04-02 09:44:55 Java

根据System.getProperty("os.name")值得判断publicclassOS{publicenumPlatformEnum{MAC,LINUX,WINDOWS;私人静态平台枚举平台;publicstaticPlatformEnumplatform(){if(platform==null){Stringos=System.getProperty("os.name");StringosName=System.getProperty("os.name");System.out.println(osName);if(osName.startsWith("MacOS")){platform=PlatformEnum.MAC;}elseif(osName.startsWith("Windows")){platform=PlatformEnum.WINDOWS;}else{platform=PlatformEnum.LINUX;}}返回平台;}}

最新推荐
猜你喜欢