getPath getAbsolutePath和getCanonicalPath的区别
来源:互联网 发布:企业管理的数据意识 编辑:程序博客网 时间:2024/05/22 15:17
File的这三个方法在api中都有说明,仅以程序为例说明。
package test;
import java.io.File;
import java.io.IOException;
public class TestFilePath {
}
程序执行结果如下:
F:\eclipseworkspace\testejb
-----默认相对路径:取得路径不同------
..\src\test1.txt
F:\eclipseworkspace\testejb\..\src\test1.txt
F:\eclipseworkspace\src\test1.txt
-----默认相对路径:取得路径不同------
.\test1.txt
F:\eclipseworkspace\testejb\.\test1.txt
F:\eclipseworkspace\testejb\test1.txt
-----默认绝对路径:取得路径相同------
D:\workspace\test\test1.txt
D:\workspace\test\test1.txt
D:\workspace\test\test1.txt
结论:
当输入为绝对路径时,返回的都是绝对路径。
当输入为相对路径时:
getPath()返回的是File构造方法里的路径,是什么就是什么,不增不减
getAbsolutePath()返回的其实是user.dir+getPath()的内容,从上面F:\eclipseworkspace\testejb、F:\eclipseworkspace\testejb\..\src\test1.txt、F:\eclipseworkspace\testejb\.\test1.txt可以得出。
getCanonicalPath()返回的就是标准的将符号完全解析的路径- getPath getAbsolutePath和getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath(), getAbsolutePath()和 getCanonicalPath() 的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath(),getAbsolutePath(),getCanonicalPath()区别
- File的getPath()和getAbsolutePath()和getCanonicalPath()的区别
- file中getPath()和getAbsolutePath()和getCanonicalPath()方法的区别
- 获取文件路径,getCanonicalPath、getAbsolutePath和getPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- File的getPath(),getAbsolutePath(),getCanonicalPath()区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的不同
- Java getPath() getAbsolutePath() getCanonicalPath()区别
- POJ1837Balance(分组背包)
- 常用压缩命令
- android内存优化
- socket程序异常终止
- 关于readdir返回值中struct dirent.d_type的取值问题
- getPath getAbsolutePath和getCanonicalPath的区别
- 22222
- Scala中的隐式转换、隐式参数、隐式类
- 第一个php程序
- Android 中的接口回调
- OpenGL之VBO,PBO,FBO技术
- 三维引擎设计专题--大气散射特效
- 愉快的开始,Java初探
- EditText 设置 左上角 光标