梦幻之旅

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 阅读(336) 评论(0)  编辑  收藏 所属分类: Linux

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


网站导航: