您的位置:首页 > 运维架构 > Linux

java区分linux系统还是windows系统

2014-06-30 00:00 274 查看
偶尔会出现这样的情况:在windows上开发,在linux上运行。由于两个系统的一些区别,可能要对代码做一些调整。为避免这样的麻烦,还是加个判断好了。

if(System.getProperty("os.name").toLowerCase().indexOf("linux") >=0){
System.out.println("==========os.name:"+System.getProperty("os.name"));
}else if(System.getProperty("os.name").toLowerCase().indexOf("windows") >=0){
System.out.println("==========os.name:"+System.getProperty("os.name"))
}else{
System.out.println("==========other os.name:"+System.getProperty("os.name"));
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java 区分