jinfeng_wang

G-G-S,D-D-U!

BlogJava 首页 新随笔 联系 聚合 管理
  400 Posts :: 0 Stories :: 296 Comments :: 0 Trackbacks
http://tolstoy.com/samizdat/sysprops.html  
    ==》 给出了许多OS下的具体java.getproperties()的值

http://www.rgagnon.com/javadetails/java-0150.html
    ==》
  

I found that, on Windows 2003 server, the property value for "os.name" is actually "windows 2003." So either that has to be added to the bunch of tests or just relax the comparison strings a bit:

  else if ( (OS.indexOf("nt") > -1)
|| (OS.indexOf("windows 2000") > -1 )
|| (OS.indexOf("windows 2003") > -1 )  // works but is quite specific to 2003
|| (OS.indexOf("windows xp") > -1) ) {
else if ( (OS.indexOf("nt") > -1)
|| (OS.indexOf("windows 20") > -1 )  // probably is better since no other OS would return "windows" anyway
|| (OS.indexOf("windows xp") > -1) ) {
I started with "windows 200" but thought "what the hell" and made it "windows 20" to lengthen its longivity. You could push it further and use "windows 2," I suppose. The only thing to watch out for is to not overlap with "windows 9." 
 





结论:
如果可以,尽量使用变量,定义操作系统的类型,然后在不同的操作系统下修改操作系统类型的定义。否则,可能会随着操作系统以后的变化,引入新的OS Name(毕竟无法保证可以对所有的OS Name进行充分的判断)。
posted on 2007-04-18 14:20 jinfeng_wang 阅读(432) 评论(0)  编辑  收藏 所属分类: javaZZ

只有注册用户登录后才能发表评论。


网站导航: