夢(mèng)幻之旅

          DEBUG - 天道酬勤

             :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            671 隨筆 :: 6 文章 :: 256 評(píng)論 :: 0 Trackbacks
              要得到web application中的classes路徑可以使用如下方法:
              1.先查出是WINDOWS操作系統(tǒng)還是LINUX操作系統(tǒng):
          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) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): Linux
          主站蜘蛛池模板: 九龙县| 绥芬河市| 电白县| 上饶市| 酒泉市| 太仆寺旗| 甘泉县| 保山市| 开远市| 阿克| 新安县| 杭锦旗| 松潘县| 景宁| 抚州市| 惠州市| 抚宁县| 肥西县| 兴国县| 交口县| 余姚市| 云和县| 海阳市| 内黄县| 泰兴市| 惠水县| 若尔盖县| 青神县| 朝阳市| 泽普县| 庆城县| 朔州市| 香港| 永春县| 准格尔旗| 孝昌县| 禄劝| 上虞市| 垫江县| 江孜县| 常州市|