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. }
  • 相关阅读:
    WPF,WinForm调用WCF RIA
    使用c#调用XMLHTTP(XMLHTTPClass) ,发送和返回 json
    WPF 不能dll添加引用的问题
    ORACLE 10g下载|ORACLE 10g下载地址|ORACLE 10g官网下载地址
    写给我们这些浮躁的程序员
    oracle 10g 几个版本jdbc驱动下载
    List对象排序通用方法
    SQL 常用的计算时间的方法
    JAVA帮助文档全系列 JDK1.5 JDK1.6 JDK1.7 官方中英完整版下载
    Integer 自动装箱机制
  • 原文地址:https://www.cnblogs.com/jackydalong/p/2483265.html
Copyright © 2011-2022 走看看