Chinaunix首页 | 论坛 | 博客
  • 博客访问: 91400
  • 博文数量: 26
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 291
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-22 16:05
文章分类
文章存档

2014年(26)

分类: Java

2014-04-01 09:13:57

String path = PathKit.class.getResource("/").toURI().getPath();

//path=/D:/AndroidWorkspace/JFinal1.6/bin/


return new File(path).getParentFile().getParentFile().getCanonicalPath();

//D:\AndroidWorkspace


* new File("..\path\abc.txt") 中的三个方法获取路径的方法

* 1: getPath() 获取相对路径,例如   ..\path\abc.txt

* 2: getAbslutlyPath() 获取绝对路径,但可能包含 ".." 或 "." 字符,例如  D:\otherPath\..\path\abc.txt

* 3: getCanonicalPath() 获取绝对路径,但不包含 ".." 或 "." 字符,例如  D:\path\abc.txt
阅读(1960) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~