首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

途径的获得方法

2012-11-03 
路径的获得方法获取路径的方法:???System.out.println(path1:+this.getClass().getResource(/).getPat

路径的获得方法

获取路径的方法:

?

??System.out.println("path1:"+this.getClass().getResource("/").getPath().replaceAll("%20", " "));


??System.out.println("path2:"+Thread.currentThread().getContextClassLoader().getResource("").toString().replaceAll("%20", " "));??


??System.out.println("path3:"+MyTest.class.getClassLoader().getResource("").toString().replaceAll("%20", " "));


??System.out.println("path4:"+ClassLoader.getSystemResource(""));??


??System.out.println("path5:"+MyTest.class.getResource("").toString().replaceAll("%20", " "));??


??String tmp = MyTest.class.getResource("").toString().replaceAll("%20", " ");
??String str = tmp.substring(tmp.indexOf(":")+1,tmp.indexOf("/WEB-INF/classes/")+"/WEB-INF/classes/".length());
??System.out.println("path6:"+str);


??System.out.println("path7:"+MyTest.class.getResource("/").toString().replaceAll("%20", " "));


??System.out.println("path8:"+new File("/").getAbsolutePath());??


??System.out.println("path9:"+System.getProperty("user.dir"));
??
??tmp = System.getProperty("user.dir");
??str = "/"+tmp.replaceAll("\\\", "/")+"/";
??System.out.println("path10:"+str);

?

Tomcat 服务器中输出信息:

path1:/C:/tool/Tomcat 6.0/webapps/test/WEB-INF/classes/
path2:file:/C:/tool/Tomcat 6.0/webapps/test/WEB-INF/classes/
path3:file:/C:/tool/Tomcat 6.0/webapps/test/WEB-INF/classes/
path4:null
path5:file:/C:/tool/Tomcat 6.0/webapps/test/WEB-INF/classes/com/zht/test/
path6:/C:/tool/Tomcat 6.0/webapps/test/WEB-INF/classes/
path7:file:/C:/tool/Tomcat 6.0/webapps/test/WEB-INF/classes/
path8:C:\
path9:C:\tool\Tomcat 6.0\bin
path10:/C:/tool/Tomcat 6.0/bin/

?

Weblogic?服务器中输出信息:

path1:/C:/tool/BEA/weblogic92/common/lib/
path2:file:/C:/tool/BEA/weblogic92/common/lib/
path3:file:/C:/tool/BEA/weblogic92/common/lib/
path4:file:/C:/tool/BEA/weblogic92/common/lib/
path5:file:/C:/tool/BEA/user_projects/domains/Firstdomain/autodeploy/test/WEB-INF/classes/com/zht/test/
path6:/C:/tool/BEA/user_projects/domains/Firstdomain/autodeploy/test/WEB-INF/classes/
path7:file:/C:/tool/BEA/weblogic92/common/lib/
path8:C:\
path9:C:\tool\BEA\user_projects\domains\Firstdomain
path10:/C:/tool/BEA/user_projects/domains/Firstdomain/

?

热点排行