zoukankan      html  css  js  c++  java
  • Java 判断 OS 类型

      1. public class OSValidator{  
      2.    
      3.     public static void main(String[] args)  
      4.     {  
      5.         if(isWindows()){  
      6.             System.out.println("This is Windows");  
      7.         }else if(isMac()){  
      8.             System.out.println("This is Mac");  
      9.         }else if(isUnix()){  
      10.             System.out.println("This is Unix or Linux");  
      11.         }else{  
      12.             System.out.println("Your OS is not support!!");  
      13.         }  
      14.     }  
      15.    
      16.     public static boolean isWindows(){  
      17.    
      18.         String os = System.getProperty("os.name").toLowerCase();  
      19.         //windows  
      20.         return (os.indexOf( "win" ) >= 0);   
      21.    
      22.     }  
      23.    
      24.     public static boolean isMac(){  
      25.    
      26.         String os = System.getProperty("os.name").toLowerCase();  
      27.         //Mac  
      28.         return (os.indexOf( "mac" ) >= 0);   
      29.    
      30.     }  
      31.    
      32.     public static boolean isUnix(){  
      33.    
      34.         String os = System.getProperty("os.name").toLowerCase();  
      35.         //linux or unix  
      36.         return (os.indexOf( "nix") >=0 || os.indexOf( "nux") >=0);  
      37.    
      38.     }  
      39. }
  • 相关阅读:
    Luogu P1596 [USACO10OCT]湖计数Lake Counting
    Luogu P1757 通天之分组背包
    数据建模笔记1
    单纯形算法 matlab
    有效集 matlab代码
    拟牛顿 DFP matlab
    FR共轭梯度法 matlab
    整数规划
    线性规划 Matlab
    远期、期货和互换(三)
  • 原文地址:https://www.cnblogs.com/jackydalong/p/2483265.html
Copyright © 2011-2022 走看看