当前位置: 代码迷 >> Web前端 >> java 途径的读取
  详细解决方案

java 途径的读取

热度:303   发布时间:2012-09-28 00:03:35.0
java 路径的读取
http://teamojiao.iteye.com/blog/446615 //这里也有一遍blog
?//E:\Jwork\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\
jquerytest\WEB-INF\classes\image\

System.out.println(ServletActionContext.getRequest().getSession().
getServletContext().getRealPath("/WEB-INF/classes/image/"));

//jquerytest
System.out.println(ServletActionContext.getRequest().getSession().
getServletContext().getContextPath());

// 获取被编译的文件路径  .getClassLoader() /E:/Jwork/jquerytest/build/classes/
System.out.println(Test.class.getClassLoader().getResource("").getPath());

//获取当前系统目录   /E:/Jwork/jquerytest/build/classes/cn/easier/
System.out.println(Test.class.getResource("").getPath());

//获取当前工程的绝对目录 E:\Jwork\jquerytest
String path= System.getProperty("user.dir");

System.out.println(path);
File file=new File(path);
System.out.println(file.exists());
System.out.println(file.mkdirs());
  相关解决方案