您的位置:首页 > 其它

获得当前所在项根路径的方法

2011-03-29 15:34 78 查看
public static void main(String[] args) {
System.out.println(Thread.currentThread().getContextClassLoader().getResource(""));
System.out.println(HibernateMappingManager.class.getClassLoader().getResource(""));
System.out.println(ClassLoader.getSystemResource(""));
System.out.println(HibernateMappingManager.class.getResource(""));
System.out.println(HibernateMappingManager.class.getResource("/")); // Class文件所在路径
System.out.println(new File("/").getAbsolutePath());
System.out.println(System.getProperty("user.dir"));
String rootSrc = System.getProperty("user.dir");
String xmlSrc = rootSrc + "//hrJava//config//hbmxml";
System.out.println(xmlSrc);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: