夢幻之旅

          DEBUG - 天道酬勤

             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks
              要得到web application中的classes路徑可以使用如下方法:
              1.先查出是WINDOWS操作系統還是LINUX操作系統:
          private boolean isWindows(){
                  String operatorSystemName 
          = System.getProperty("os.name");
                  operatorSystemName 
          = operatorSystemName.toUpperCase();
                  
          if(operatorSystemName.indexOf("WIN")>0){
                      
          return true;
                  }

                  
          return false;
              }
              2.得到classes路徑:
          String path = null;
          path 
          = this.getClass().getResource("/"+ "Senders.txt";
          path 
          = path.substring(6,path.length());
          if(!this.isWindows()){
              path 
          += "/" + path;
          }
              例外,在windows一般文本換行符為:"\r\n",而在liunx之中則為:"\n".
          posted on 2007-12-25 14:42 HUIKK 閱讀(357) 評論(0)  編輯  收藏 所屬分類: Linux
          主站蜘蛛池模板: 昌吉市| 望都县| 醴陵市| 托克托县| 本溪| 漳浦县| 奈曼旗| 蒙阴县| 博乐市| 浮山县| 定西市| 永清县| 南靖县| 永定县| 合川市| 蒙自县| 淳安县| 新干县| 安仁县| 甘谷县| 盐津县| 宣恩县| 郁南县| 中牟县| 西华县| 金溪县| 松桃| 曲靖市| 安庆市| 新乐市| 马龙县| 时尚| 马山县| 临泽县| 军事| 朝阳市| 彭山县| 高邑县| 抚松县| 肇源县| 阿尔山市|