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 閱讀(437) 評論(0)  編輯  收藏 所屬分類: javaZZ
          主站蜘蛛池模板: 正蓝旗| 新竹县| 崇仁县| 达孜县| 台南市| 庆城县| 鲁山县| 得荣县| 永修县| 遂宁市| 诏安县| 乌兰察布市| 张家港市| 连云港市| 信丰县| 本溪市| 瓦房店市| 故城县| 南涧| 柯坪县| 高州市| 临漳县| 龙里县| 海城市| 广元市| 通榆县| 甘孜县| 辽阳市| 枣庄市| 佛坪县| 凉城县| 邵武市| 舞钢市| 五原县| 寿宁县| 嘉善县| 南靖县| 浙江省| 南皮县| 永州市| 普格县|